Skip to content

Commit 2836276

Browse files
authored
fix(hmr): make watcher ignore build.outDir (#15326)
1 parent 8ccf722 commit 2836276

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

docs/config/server-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default defineConfig({
202202

203203
File system watcher options to pass on to [chokidar](https://github.com/paulmillr/chokidar#api).
204204

205-
The Vite server watcher watches the `root` and skips the `.git/` and `node_modules/` directories by default. When updating a watched file, Vite will apply HMR and update the page only if needed.
205+
The Vite server watcher watches the `root` and skips the `.git/`, `node_modules/`, and Vite's `cacheDir` and `build.outDir` directories by default. When updating a watched file, Vite will apply HMR and update the page only if needed.
206206

207207
If set to `null`, no files will be watched. `server.watcher` will provide a compatible event emitter, but calling `add` or `unwatch` will have no effect.
208208

packages/vite/src/node/watch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EventEmitter } from 'node:events'
2+
import path from 'node:path'
23
import glob from 'fast-glob'
34
import type { FSWatcher, WatchOptions } from 'dep-types/chokidar'
45
import { arraify } from './utils'
@@ -16,6 +17,7 @@ export function resolveChokidarOptions(
1617
'**/node_modules/**',
1718
'**/test-results/**', // Playwright
1819
glob.escapePath(config.cacheDir) + '/**',
20+
glob.escapePath(path.resolve(config.root, config.build.outDir)) + '/**',
1921
...arraify(ignored),
2022
],
2123
ignoreInitial: true,

0 commit comments

Comments
 (0)