Skip to content

Commit 1d263d3

Browse files
authored
fix(watch): build watch fails when outDir is empty string (#15979)
1 parent 81b3bd0 commit 1d263d3

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/vite/src/node/watch.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ export function resolveChokidarOptions(
99
config: ResolvedConfig,
1010
options: WatchOptions | undefined,
1111
): WatchOptions {
12-
const { ignored = [], ...otherOptions } = options ?? {}
12+
const { ignored: ignoredList, ...otherOptions } = options ?? {}
13+
const ignored: WatchOptions['ignored'] = [
14+
'**/.git/**',
15+
'**/node_modules/**',
16+
'**/test-results/**', // Playwright
17+
glob.escapePath(config.cacheDir) + '/**',
18+
...arraify(ignoredList || []),
19+
]
20+
if (config.build.outDir) {
21+
ignored.push(
22+
glob.escapePath(path.resolve(config.root, config.build.outDir)) + '/**',
23+
)
24+
}
1325

1426
const resolvedWatchOptions: WatchOptions = {
15-
ignored: [
16-
'**/.git/**',
17-
'**/node_modules/**',
18-
'**/test-results/**', // Playwright
19-
glob.escapePath(config.cacheDir) + '/**',
20-
glob.escapePath(path.resolve(config.root, config.build.outDir)) + '/**',
21-
...arraify(ignored),
22-
],
27+
ignored,
2328
ignoreInitial: true,
2429
ignorePermissionErrors: true,
2530
...otherOptions,

0 commit comments

Comments
 (0)