diff --git a/v2/cmd/wails/flags/dev.go b/v2/cmd/wails/flags/dev.go index 6d4f02f95..7e5e6239c 100644 --- a/v2/cmd/wails/flags/dev.go +++ b/v2/cmd/wails/flags/dev.go @@ -22,6 +22,7 @@ type Dev struct { Browser bool `flag:"browser" description:"Open the application in a browser"` NoReload bool `flag:"noreload" description:"Disable reload on asset change"` NoColour bool `flag:"nocolor" description:"Disable colour in output"` + NoGoRebuild bool `flag:"nogorebuild" description:"Disable automatic rebuilding on backend file changes/additions"` WailsJSDir string `flag:"wailsjsdir" description:"Directory to generate the Wails JS modules"` LogLevel string `flag:"loglevel" description:"LogLevel to use - Trace, Debug, Info, Warning, Error)"` ForceBuild bool `flag:"f" description:"Force build of application"` diff --git a/v2/cmd/wails/internal/dev/dev.go b/v2/cmd/wails/internal/dev/dev.go index 8d11edbf7..6ec801119 100644 --- a/v2/cmd/wails/internal/dev/dev.go +++ b/v2/cmd/wails/internal/dev/dev.go @@ -80,7 +80,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error { // Setup signal handler quitChannel := make(chan os.Signal, 1) - signal.Notify(quitChannel, os.Interrupt, os.Kill, syscall.SIGTERM) + signal.Notify(quitChannel, os.Interrupt, syscall.SIGTERM) exitCodeChannel := make(chan int, 1) // Build the frontend if requested, but ignore building the application itself. @@ -255,8 +255,8 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d const ( stateRunning int32 = 0 - stateCanceling = 1 - stateStopped = 2 + stateCanceling int32 = 1 + stateStopped int32 = 2 ) state := stateRunning go func() { @@ -366,7 +366,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc assetDirURL := joinPath(devServerURL, "/wails/assetdir") reloadURL := joinPath(devServerURL, "/wails/reload") - for quit == false { + for !quit { // reload := false select { case exitCode := <-exitCodeChannel: @@ -441,16 +441,21 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc case <-timer.C: if rebuild { rebuild = false - logutils.LogGreen("[Rebuild triggered] files updated") - // Try and build the app - newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme) - if err != nil { - logutils.LogRed("Error during build: %s", err.Error()) - continue - } - // If we have a new process, saveConfig it - if newBinaryProcess != nil { - debugBinaryProcess = newBinaryProcess + if f.NoGoRebuild { + logutils.LogGreen("[Rebuild triggered] skipping due to flag -nogorebuild") + } else { + logutils.LogGreen("[Rebuild triggered] files updated") + // Try and build the app + + newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme) + if err != nil { + logutils.LogRed("Error during build: %s", err.Error()) + continue + } + // If we have a new process, saveConfig it + if newBinaryProcess != nil { + debugBinaryProcess = newBinaryProcess + } } } diff --git a/v2/cmd/wails/wails b/v2/cmd/wails/wails new file mode 100755 index 000000000..75251b41d Binary files /dev/null and b/v2/cmd/wails/wails differ diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index efaba12db..721d43a8f 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added new community template wails-sveltekit-ts. Added by [@haukened](https://github.com/haukened) in [PR](https://github.com/wailsapp/wails/pull/2851) - Added support for retrieving the logical and physical screen size in the screen api. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2856) - Added new community template wails-sveltekit-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2851) +- Added new `wails dev -nogorebuild` flag to prevent restarts on back end file changes. [@haukened](https://github.com/haukened) in [PR #2870](https://github.com/wailsapp/wails/pull/2870) ### Changed diff --git a/website/versioned_docs/version-v2.5.0/reference/cli.mdx b/website/versioned_docs/version-v2.5.0/reference/cli.mdx index c76baaadd..684dd88b4 100644 --- a/website/versioned_docs/version-v2.5.0/reference/cli.mdx +++ b/website/versioned_docs/version-v2.5.0/reference/cli.mdx @@ -179,6 +179,7 @@ Your system is ready for Wails development! | -ldflags "flags" | Additional ldflags to pass to the compiler | | | -tags "extra tags" | Build tags to pass to compiler (quoted and space separated) | | | -loglevel "loglevel" | Loglevel to use - Trace, Debug, Info, Warning, Error | Debug | +| -nogoreload | Disable back end rebuilds on file change/create/delete. Useful for IDEs that autosave frequently. | | | -noreload | Disable automatic reload when assets change | | | -nocolour | Turn off colour cli output | false | | -nogen | Disable generate module | |