Skip to content

Commit

Permalink
fix(watch): build watch fails when outDir is empty string (#15979)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Feb 20, 2024
1 parent 81b3bd0 commit 1d263d3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/vite/src/node/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ export function resolveChokidarOptions(
config: ResolvedConfig,
options: WatchOptions | undefined,
): WatchOptions {
const { ignored = [], ...otherOptions } = options ?? {}
const { ignored: ignoredList, ...otherOptions } = options ?? {}
const ignored: WatchOptions['ignored'] = [
'**/.git/**',
'**/node_modules/**',
'**/test-results/**', // Playwright
glob.escapePath(config.cacheDir) + '/**',
...arraify(ignoredList || []),
]
if (config.build.outDir) {
ignored.push(
glob.escapePath(path.resolve(config.root, config.build.outDir)) + '/**',
)
}

const resolvedWatchOptions: WatchOptions = {
ignored: [
'**/.git/**',
'**/node_modules/**',
'**/test-results/**', // Playwright
glob.escapePath(config.cacheDir) + '/**',
glob.escapePath(path.resolve(config.root, config.build.outDir)) + '/**',
...arraify(ignored),
],
ignored,
ignoreInitial: true,
ignorePermissionErrors: true,
...otherOptions,
Expand Down

0 comments on commit 1d263d3

Please sign in to comment.