mirror of
https://github.com/zhigang1992/esbuild.git
synced 2026-01-12 17:13:19 +08:00
implement custom output paths for entry points
This commit is contained in:
@@ -271,7 +271,9 @@ type BuildOptions struct {
|
||||
ChunkNames string
|
||||
AssetNames string
|
||||
|
||||
EntryPoints []string
|
||||
EntryPoints []string
|
||||
EntryPointsAdvanced []EntryPoint
|
||||
|
||||
Stdin *StdinOptions
|
||||
Write bool
|
||||
Incremental bool
|
||||
@@ -280,6 +282,11 @@ type BuildOptions struct {
|
||||
Watch *WatchMode
|
||||
}
|
||||
|
||||
type EntryPoint struct {
|
||||
InputPath string
|
||||
OutputPath string
|
||||
}
|
||||
|
||||
type WatchMode struct {
|
||||
OnRebuild func(BuildResult)
|
||||
}
|
||||
|
||||
@@ -792,7 +792,13 @@ func rebuildImpl(
|
||||
for i, path := range buildOpts.NodePaths {
|
||||
options.AbsNodePaths[i] = validatePath(log, realFS, path, "node path")
|
||||
}
|
||||
entryPoints := append([]string{}, buildOpts.EntryPoints...)
|
||||
entryPoints := make([]bundler.EntryPoint, 0, len(buildOpts.EntryPoints)+len(buildOpts.EntryPointsAdvanced))
|
||||
for _, ep := range buildOpts.EntryPoints {
|
||||
entryPoints = append(entryPoints, bundler.EntryPoint{InputPath: ep})
|
||||
}
|
||||
for _, ep := range buildOpts.EntryPointsAdvanced {
|
||||
entryPoints = append(entryPoints, bundler.EntryPoint{InputPath: ep.InputPath, OutputPath: ep.OutputPath})
|
||||
}
|
||||
entryPointCount := len(entryPoints)
|
||||
if buildOpts.Stdin != nil {
|
||||
entryPointCount++
|
||||
|
||||
@@ -458,7 +458,14 @@ func parseOptionsImpl(
|
||||
return fmt.Errorf("Unexpected single quote character before flag (use \\\" to escape double quotes): %s", arg), nil
|
||||
|
||||
case !strings.HasPrefix(arg, "-") && buildOpts != nil:
|
||||
buildOpts.EntryPoints = append(buildOpts.EntryPoints, arg)
|
||||
if equals := strings.IndexByte(arg, '='); equals != -1 {
|
||||
buildOpts.EntryPointsAdvanced = append(buildOpts.EntryPointsAdvanced, api.EntryPoint{
|
||||
OutputPath: arg[:equals],
|
||||
InputPath: arg[equals+1:],
|
||||
})
|
||||
} else {
|
||||
buildOpts.EntryPoints = append(buildOpts.EntryPoints, arg)
|
||||
}
|
||||
|
||||
default:
|
||||
if buildOpts != nil {
|
||||
@@ -606,7 +613,7 @@ func runImpl(osArgs []string) int {
|
||||
}
|
||||
|
||||
// Read from stdin when there are no entry points
|
||||
if len(buildOptions.EntryPoints) == 0 {
|
||||
if len(buildOptions.EntryPoints)+len(buildOptions.EntryPointsAdvanced) == 0 {
|
||||
if buildOptions.Stdin == nil {
|
||||
buildOptions.Stdin = &api.StdinOptions{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user