New command structure. Add replace command.
This commit is contained in:
31
build.go
Normal file
31
build.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user