2022-09-28 10:10:01 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-09-28 10:10:01 +02:00
|
|
|
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
|
|
|
|
}
|