Skip to content

Commit

Permalink
fix: cacheDir should be watch-ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 25, 2022
1 parent 71eaacf commit 23d2e85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/vite/src/node/build.ts
Expand Up @@ -574,6 +574,7 @@ async function doBuild(
}

const resolvedChokidarOptions = resolveChokidarOptions(
config,
config.build.watch.chokidar
)

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Expand Up @@ -304,7 +304,7 @@ export async function createServer(
const httpsOptions = await resolveHttpsConfig(config.server.https)
const { middlewareMode } = serverConfig

const resolvedWatchOptions = resolveChokidarOptions({
const resolvedWatchOptions = resolveChokidarOptions(config, {
disableGlobbing: true,
...serverConfig.watch
})
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/watch.ts
@@ -1,6 +1,9 @@
import path from 'node:path'
import type { WatchOptions } from 'dep-types/chokidar'
import type { ResolvedConfig } from '.'

export function resolveChokidarOptions(
config: ResolvedConfig,
options: WatchOptions | undefined
): WatchOptions {
const { ignored = [], ...otherOptions } = options ?? {}
Expand All @@ -10,6 +13,7 @@ export function resolveChokidarOptions(
'**/.git/**',
'**/node_modules/**',
'**/test-results/**', // Playwright
path.relative(config.root, config.cacheDir + '/**'),
...(Array.isArray(ignored) ? ignored : [ignored])
],
ignoreInitial: true,
Expand Down

0 comments on commit 23d2e85

Please sign in to comment.