Skip to content

Commit

Permalink
feat: allow passing down "null" to disable server watcher (#14208)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
sheremet-va and bluwy authored Sep 19, 2023
1 parent 7485fe7 commit 27a6838
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ The error that appears in the Browser when the fallback happens can be ignored.

## server.watch

- **Type:** `object`
- **Type:** `object | null`

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

Expand All @@ -197,6 +197,8 @@ export default defineConfig({
})
```

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.

::: warning Using Vite on Windows Subsystem for Linux (WSL) 2

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.
Expand Down
3 changes: 2 additions & 1 deletion guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ interface ViteDevServer {
*/
httpServer: http.Server | null
/**
* Chokidar watcher instance.
* Chokidar watcher instance. If `config.server.watch` is set to `null`,
* returns a noop event emitter.
* https://github.com/paulmillr/chokidar#api
*/
watcher: FSWatcher
Expand Down

0 comments on commit 27a6838

Please sign in to comment.