Compare commits
	
		
			2 Commits
		
	
	
		
			4.3.1
			...
			30f8be3d5d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 30f8be3d5d | |||
| c356f34e21 | 
							
								
								
									
										15
									
								
								build.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								build.go
									
									
									
									
									
								
							@@ -1,7 +1,9 @@
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"os/exec"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/evanw/esbuild/pkg/api"
 | 
						"github.com/evanw/esbuild/pkg/api"
 | 
				
			||||||
@@ -34,6 +36,19 @@ func buildAction(ctx *cli.Context) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		api.Build(o.ESBuild.BuildOptions)
 | 
							api.Build(o.ESBuild.BuildOptions)
 | 
				
			||||||
		replace(o)
 | 
							replace(o)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ctx.Bool("p") && o.ProductionBuildOptions.CmdPostBuild != "" {
 | 
				
			||||||
 | 
								fmt.Printf("Executing post production build command `%s`\n", o.ProductionBuildOptions.CmdPostBuild)
 | 
				
			||||||
 | 
								cmd := exec.Command("sh", "-c", o.ProductionBuildOptions.CmdPostBuild)
 | 
				
			||||||
 | 
								cmd.Stdout = os.Stdout
 | 
				
			||||||
 | 
								cmd.Stderr = os.Stderr
 | 
				
			||||||
 | 
								err := cmd.Run()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("Failed to execute post production build command `%s`: %+v\n", o.ProductionBuildOptions.CmdPostBuild, err)
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.go
									
									
									
									
									
								
							@@ -28,7 +28,7 @@ type ESBuildExtended struct {
 | 
				
			|||||||
type options struct {
 | 
					type options struct {
 | 
				
			||||||
	ESBuild ESBuildExtended
 | 
						ESBuild ESBuildExtended
 | 
				
			||||||
	Watch   struct {
 | 
						Watch   struct {
 | 
				
			||||||
		Path    string
 | 
							Paths   []string
 | 
				
			||||||
		Exclude []string
 | 
							Exclude []string
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	Serve struct {
 | 
						Serve struct {
 | 
				
			||||||
@@ -52,6 +52,9 @@ type options struct {
 | 
				
			|||||||
		From string
 | 
							From string
 | 
				
			||||||
		To   string
 | 
							To   string
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ProductionBuildOptions struct {
 | 
				
			||||||
 | 
							CmdPostBuild string
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func readCfg(cfgPath string) []options {
 | 
					func readCfg(cfgPath string) []options {
 | 
				
			||||||
@@ -89,7 +92,7 @@ func main() {
 | 
				
			|||||||
	app := &cli.App{
 | 
						app := &cli.App{
 | 
				
			||||||
		Name:    "gowebbuild",
 | 
							Name:    "gowebbuild",
 | 
				
			||||||
		Usage:   "All in one tool to build web frontend projects.",
 | 
							Usage:   "All in one tool to build web frontend projects.",
 | 
				
			||||||
		Version: "4.3.0",
 | 
							Version: "4.4.0",
 | 
				
			||||||
		Authors: []*cli.Author{{
 | 
							Authors: []*cli.Author{{
 | 
				
			||||||
			Name: "trading-peter (https://github.com/trading-peter)",
 | 
								Name: "trading-peter (https://github.com/trading-peter)",
 | 
				
			||||||
		}},
 | 
							}},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "Watch": {
 | 
					  "Watch": {
 | 
				
			||||||
    "Path": "./frontend/src",
 | 
					    "Paths": [ "./frontend/src" ],
 | 
				
			||||||
    "Exclude": [ "./dist" ]
 | 
					    "Exclude": [ "./dist" ]
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "Copy": [
 | 
					  "Copy": [
 | 
				
			||||||
@@ -45,5 +45,8 @@
 | 
				
			|||||||
    "Bundle":    true,
 | 
					    "Bundle":    true,
 | 
				
			||||||
    "Write":     true,
 | 
					    "Write":     true,
 | 
				
			||||||
    "LogLevel":  3
 | 
					    "LogLevel":  3
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "ProductionBuildOptions": {
 | 
				
			||||||
 | 
					    "CmdPostBuild": "my-build-script.sh"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								watch.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								watch.go
									
									
									
									
									
								
							@@ -38,10 +38,16 @@ func watchAction(ctx *cli.Context) error {
 | 
				
			|||||||
				w.Ignore(opts.Watch.Exclude...)
 | 
									w.Ignore(opts.Watch.Exclude...)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if err := w.AddRecursive(opts.Watch.Path); err != nil {
 | 
								if opts.ESBuild.Outdir != "" {
 | 
				
			||||||
 | 
									w.Ignore(opts.ESBuild.Outdir)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								for _, p := range opts.Watch.Paths {
 | 
				
			||||||
 | 
									if err := w.AddRecursive(p); err != nil {
 | 
				
			||||||
					fmt.Println(err.Error())
 | 
										fmt.Println(err.Error())
 | 
				
			||||||
					os.Exit(1)
 | 
										os.Exit(1)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			go func() {
 | 
								go func() {
 | 
				
			||||||
				for {
 | 
									for {
 | 
				
			||||||
@@ -60,7 +66,7 @@ func watchAction(ctx *cli.Context) error {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}()
 | 
								}()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Path)
 | 
								fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Paths)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			purge(opts)
 | 
								purge(opts)
 | 
				
			||||||
			cp(opts)
 | 
								cp(opts)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user