Ignoring outDir in Chokidar watcher introduced regression in >=5.1.0, not entirely fixed by #15979 #16248
Closed
7 tasks done
Labels
p2-to-be-discussed
Enhancement under consideration (priority)
Describe the bug
I have a legacy project migrated from Gulp where a Sass file lives within the same directory as the
outDir
. Since Vite version >=5.1.0 (specifically #15326),vite build --watch
no longer re-builds upon changes to the source Sass file. This issue is closely related to the problem described in #15951, which was fixed by the following conditional check in #15979:vite/packages/vite/src/node/watch.ts
Lines 20 to 24 in 6a07243
The difference, in my case, is that
outDir
is not an empty string and instead is its own separate directory. The common thread between this issue and #15951 is that both projects haveemptyOutDir
set to false. My suggestion to fix my issue, while still solving the issue described in #15951, would be to test foremptyOutDir
instead:The thinking here is if the
outDir
is being emptied out for every build, there is no point watching for changes within. On the other hand, if the directory isn't being emptied, it is possible that source files may be present and need to be watched for. If there's agreement around this solution, I would be more than happy to open a PR with this change and update the docs.Reproduction
https://stackblitz.com/edit/vitejs-vite-spjjif?file=vite.config.ts
Steps to reproduce
npm run build
(the script has--watch
appended tovite build
)outDir/styles.scss
and observe how saved changes do not trigger a re-buildnpm install -D [email protected]
)npm run build
againoutDir/styles.scss
trigger a re-buildSystem Info
System: OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm) CPU: (4) x64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz Memory: 12.39 GB / 15.49 GB Container: Yes Shell: 5.2.15 - /bin/bash Binaries: Node: 20.11.1 - /usr/bin/node npm: 10.2.4 - /usr/bin/npm npmPackages: vite: ^5.2.4 => 5.2.4
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: