gowebbuild/build.go

41 lines
629 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 {
2023-09-13 11:45:24 +02:00
if ctx.Bool("p") {
download(o)
}
2022-11-29 12:33:02 +01:00
purge(o)
cp(o)
if ctx.Bool("p") {
o.ESBuild.MinifyIdentifiers = true
o.ESBuild.MinifySyntax = true
o.ESBuild.MinifyWhitespace = true
o.ESBuild.Sourcemap = api.SourceMapNone
}
2022-11-29 12:33:02 +01:00
api.Build(o.ESBuild.BuildOptions)
replace(o)
}
return nil
}