5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 08:41:41 +08:00

[v2] Fix reloaddirs wails.json config (#4005)

fix reloaddirs config option

changelog.mdx
This commit is contained in:
Atterpac 2025-01-23 04:11:29 -07:00 committed by GitHub
parent 55b90a50bc
commit 00be6f24d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

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