New command structure. Add replace command.

This commit is contained in:
2022-09-28 10:10:01 +02:00
parent bea89e2a80
commit 8433170681
6 changed files with 233 additions and 152 deletions

31
build.go Normal file
View File

@ -0,0 +1,31 @@
package main
import (
"os"
"path/filepath"
"github.com/evanw/esbuild/pkg/api"
"github.com/urfave/cli/v2"
)
func buildAction(ctx *cli.Context) error {
cfgPath := ctx.String("c")
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
}