Skip to content

Commit bbb4067

Browse files
authored
docs: explain how to watch files inside node_modules (#5239)
1 parent 7255fd5 commit bbb4067

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/config/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,23 @@ export default defineConfig(async ({ command, mode }) => {
485485

486486
When running Vite on Windows Subsystem for Linux (WSL) 2, if the project folder resides in a Windows filesystem, you'll need to set this option to `{ usePolling: true }`. This is due to [a WSL2 limitation](https://github.com/microsoft/WSL/issues/4739) with the Windows filesystem.
487487

488+
The Vite server watcher skips `.git/` and `node_modules/` directories by default. If you want to watch a package inside `node_moduels/`, you can pass a negated glob pattern to `server.watch.ignored`. That is:
489+
490+
```js
491+
export default defineConfig({
492+
server: {
493+
watch: {
494+
ignored: ['!**/node_modules/your-package-name/**']
495+
}
496+
},
497+
// The watched package must be excluded from optimization,
498+
// so that it can appear in the dependency graph and trigger hot reload.
499+
optimizeDeps: {
500+
exclude: ['your-package-name']
501+
}
502+
})
503+
```
504+
488505
### server.middlewareMode
489506

490507
- **Type:** `'ssr' | 'html'`

0 commit comments

Comments
 (0)