forked from vitejs/vite
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
watch.ts
38 lines (34 loc) · 1.18 KB
/
watch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { WatchOptions } from 'types/chokidar'
import colors from 'picocolors'
import type { Logger } from './logger'
import { isWSL2 } from './utils'
export function resolveChokidarOptions(
logger: Logger,
options: WatchOptions | undefined,
optionName: string
): WatchOptions {
const { ignored = [], ...otherOptions } = options ?? {}
const resolvedWatchOptions: WatchOptions = {
ignored: [
'**/.git/**',
'**/node_modules/**',
'**/test-results/**', // Playwright
...(Array.isArray(ignored) ? ignored : [ignored])
],
ignoreInitial: true,
ignorePermissionErrors: true,
...otherOptions
}
if (isWSL2 && resolvedWatchOptions.usePolling === undefined) {
logger.warn(
colors.yellow(
colors.bold(`(!) `) +
'Default file system watching might not work with your setup due to a limitation of WSL2. ' +
'HMR and other features will not work when file system watching is not working. ' +
`To suppress this warning, set true or false to "${optionName}.usePolling". ` +
'More information: https://vitejs.dev/config/server-options.html#server-watch'
)
)
}
return resolvedWatchOptions
}