gowebbuild/build.go

37 lines
565 B
Go
Raw Permalink Normal View History

package main
import (
"os"
"path/filepath"
"github.com/evanw/esbuild/pkg/api"
"github.com/urfave/cli/v2"
)
func buildAction(ctx *cli.Context) error {
2022-11-29 10:23:42 +01:00
cfgPath, err := filepath.Abs(ctx.String("c"))
if err != nil {
return err
}
os.Chdir(filepath.Dir(cfgPath))
opts := readCfg(cfgPath)
for _, o := range opts {
cp(o)
if ctx.Bool("p") {
o.ESBuild.MinifyIdentifiers = true
o.ESBuild.MinifySyntax = true
o.ESBuild.MinifyWhitespace = true
o.ESBuild.Sourcemap = api.SourceMapNone
}
api.Build(o.ESBuild)
replace(o)
}
return nil
}