From bb0f06f673a55a99fe6e121e1821c790f4b5cec6 Mon Sep 17 00:00:00 2001 From: atterpac Date: Sun, 12 Jan 2025 19:35:26 -0700 Subject: [PATCH] fix reloaddirs config option changelog.mdx --- v2/cmd/wails/internal/dev/dev.go | 6 +++--- v2/cmd/wails/internal/dev/watcher.go | 15 +++++++++++++-- website/src/pages/changelog.mdx | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/v2/cmd/wails/internal/dev/dev.go b/v2/cmd/wails/internal/dev/dev.go index 2f6b10a7396..5cb62421b07 100644 --- a/v2/cmd/wails/internal/dev/dev.go +++ b/v2/cmd/wails/internal/dev/dev.go @@ -153,7 +153,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error { }() // Watch for changes and trigger restartApp() - debugBinaryProcess, err = doWatcherLoop(cwd, buildOptions, debugBinaryProcess, f, exitCodeChannel, quitChannel, f.DevServerURL(), legacyUseDevServerInsteadofCustomScheme) + debugBinaryProcess, err = doWatcherLoop(cwd, projectConfig.ReloadDirectories, buildOptions, debugBinaryProcess, f, exitCodeChannel, quitChannel, f.DevServerURL(), legacyUseDevServerInsteadofCustomScheme) if err != nil { return err } @@ -326,9 +326,9 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process } // doWatcherLoop is the main watch loop that runs while dev is active -func doWatcherLoop(cwd string, buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, error) { +func doWatcherLoop(cwd string, reloadDirs string, buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, error) { // create the project files watcher - watcher, err := initialiseWatcher(cwd) + watcher, err := initialiseWatcher(cwd, reloadDirs) if err != nil { logutils.LogRed("Unable to create filesystem watcher. Reloads will not occur.") return nil, err diff --git a/v2/cmd/wails/internal/dev/watcher.go b/v2/cmd/wails/internal/dev/watcher.go index 4e7457ef942..e1161f87c3e 100644 --- a/v2/cmd/wails/internal/dev/watcher.go +++ b/v2/cmd/wails/internal/dev/watcher.go @@ -4,6 +4,7 @@ import ( "bufio" "os" "path/filepath" + "strings" "github.com/wailsapp/wails/v2/internal/fs" @@ -17,7 +18,7 @@ type Watcher interface { } // initialiseWatcher creates the project directory watcher that will trigger recompile -func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) { +func initialiseWatcher(cwd, reloadDirs string) (*fsnotify.Watcher, error) { // Ignore dot files, node_modules and build directories by default ignoreDirs := getIgnoreDirs(cwd) @@ -27,12 +28,22 @@ func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) { return nil, err } + customDirs := dirs.AsSlice() + seperatedDirs := strings.Split(reloadDirs, ",") + for _, dir := range seperatedDirs { + customSub, err := fs.GetSubdirectories(filepath.Join(cwd, dir)) + if err != nil { + return nil, err + } + customDirs = append(customDirs, customSub.AsSlice()...) + } + watcher, err := fsnotify.NewWatcher() if err != nil { return nil, err } - for _, dir := range processDirectories(dirs.AsSlice(), ignoreDirs) { + for _, dir := range processDirectories(customDirs, ignoreDirs) { err := watcher.Add(dir) if err != nil { return nil, err diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 2e148afb4e4..1cc9dd158f6 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added option to set window class name on Windows. Added in [PR](https://github.com/wailsapp/wails/pull/3828) by @APshenkin ### Fixed +- Fixed `reloaddirs` wails.json config options by @atterpac in [#4005](https//github.com/wailsapp/wails/pull/4005) - Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying) - Using go-webview2 v0.1.17 to fix native webview2loader issue, by @leaanthony - Fixed example for macOS menu by @takuyahara in [PR](https://github.com/wailsapp/wails/pull/3847)