Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] Fix reloaddirs wails.json config #4005

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions v2/cmd/wails/internal/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions v2/cmd/wails/internal/dev/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"os"
"path/filepath"
"strings"

"github.com/wailsapp/wails/v2/internal/fs"

Expand All @@ -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)

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down