Skip to content

Commit 27a6838

Browse files
sheremet-vabluwy
andauthored
feat: allow passing down "null" to disable server watcher (#14208)
Co-authored-by: Bjorn Lu <[email protected]>
1 parent 7485fe7 commit 27a6838

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

config/server-options.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ The error that appears in the Browser when the fallback happens can be ignored.
176176

177177
## server.watch
178178

179-
- **Type:** `object`
179+
- **Type:** `object | null`
180180

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

@@ -197,6 +197,8 @@ export default defineConfig({
197197
})
198198
```
199199

200+
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.
201+
200202
::: warning Using Vite on Windows Subsystem for Linux (WSL) 2
201203

202204
When running Vite on WSL2, file system watching does not work when a file is edited by Windows applications (non-WSL2 process). This is due to [a WSL2 limitation](https://github.com/microsoft/WSL/issues/4739). This also applies to running on Docker with a WSL2 backend.

guide/api-javascript.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ interface ViteDevServer {
7575
*/
7676
httpServer: http.Server | null
7777
/**
78-
* Chokidar watcher instance.
78+
* Chokidar watcher instance. If `config.server.watch` is set to `null`,
79+
* returns a noop event emitter.
7980
* https://github.com/paulmillr/chokidar#api
8081
*/
8182
watcher: FSWatcher

0 commit comments

Comments
 (0)