mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
[v2] Introduce frontend:dev:watcher command (#1170)
This commit is contained in:
parent
451b0c1e15
commit
ff8e701793
3 changed files with 12 additions and 8 deletions
|
|
@ -142,10 +142,10 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// frontend:dev server command. *Not concurrent*
|
||||
if projectConfig.DevCommand != "" {
|
||||
// frontend:dev:watcher command.
|
||||
if command := projectConfig.DevWatcherCommand; command != "" {
|
||||
var devCommandWaitGroup sync.WaitGroup
|
||||
closer := runFrontendDevCommand(cwd, projectConfig.DevCommand, &devCommandWaitGroup)
|
||||
closer := runFrontendDevWatcherCommand(cwd, command, &devCommandWaitGroup)
|
||||
defer closer(&devCommandWaitGroup)
|
||||
}
|
||||
|
||||
|
|
@ -368,9 +368,9 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
|
|||
return projectConfig, nil
|
||||
}
|
||||
|
||||
// runFrontendDevCommand will run the `frontend:dev` command if it was given, ex- `npm run dev`
|
||||
func runFrontendDevCommand(cwd string, devCommand string, wg *sync.WaitGroup) func(group *sync.WaitGroup) {
|
||||
LogGreen("Running frontend dev command: '%s'", devCommand)
|
||||
// runFrontendDevWatcherCommand will run the `frontend:dev:watcher` command if it was given, ex- `npm run dev`
|
||||
func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGroup) func(group *sync.WaitGroup) {
|
||||
LogGreen("Running frontend dev watcher command: '%s'", devCommand)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
dir := filepath.Join(cwd, "frontend")
|
||||
cmdSlice := strings.Split(devCommand, " ")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ type Project struct {
|
|||
|
||||
BuildCommand string `json:"frontend:build"`
|
||||
InstallCommand string `json:"frontend:install"`
|
||||
DevCommand string `json:"frontend:dev"`
|
||||
|
||||
// Commands used in `wails dev`
|
||||
DevCommand string `json:"frontend:dev"`
|
||||
DevWatcherCommand string `json:"frontend:dev:watcher"`
|
||||
|
||||
// Directory to generate the API Module
|
||||
WailsJSDir string `json:"wailsjsdir"`
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ The project config resides in the `wails.json` file in the project directory. Th
|
|||
"reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]",
|
||||
"frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]",
|
||||
"frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]",
|
||||
"frontend:dev": "[This command is the dev equivalent of frontend:build]",
|
||||
"frontend:dev": "[This command is the dev equivalent of frontend:build. If not specified falls back to frontend:build]",
|
||||
"frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers]",
|
||||
"wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]",
|
||||
"version": "[Project config version]",
|
||||
"outputfilename": "[The name of the binary]",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue