From a302fe806244154c3ed3a2bc98574d148d09e3b0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 31 May 2023 14:11:46 +0100 Subject: [PATCH] perf(nuxt): avoid watching nested paths (#21256) --- packages/nuxt/src/core/builder.ts | 2 +- packages/schema/src/config/common.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/builder.ts b/packages/nuxt/src/core/builder.ts index 3638c84263..9a397d4e9a 100644 --- a/packages/nuxt/src/core/builder.ts +++ b/packages/nuxt/src/core/builder.ts @@ -116,7 +116,7 @@ function createGranularWatcher () { watchers[path].close() delete watchers[path] } - if (event === 'addDir' && path !== dir && !ignoredDirs.has(path) && !(path in watchers) && !isIgnored(path)) { + if (event === 'addDir' && path !== dir && !ignoredDirs.has(path) && !pathsToWatch.includes(path) && !(path in watchers) && !isIgnored(path)) { watchers[path] = chokidar.watch(path, { ...nuxt.options.watchers.chokidar, ignored: [isIgnored] }) watchers[path].on('all', (event, path) => nuxt.callHook('builder:watch', event, normalize(path))) nuxt.hook('close', () => watchers[path].close()) diff --git a/packages/schema/src/config/common.ts b/packages/schema/src/config/common.ts index a60746a7fe..1e13d6c269 100644 --- a/packages/schema/src/config/common.ts +++ b/packages/schema/src/config/common.ts @@ -357,6 +357,7 @@ export default defineUntypedSchema({ '**/*.d.ts', // ignore type declarations '.output', '.git', + '.cache', await get('analyzeDir'), await get('buildDir'), await get('ignorePrefix') && `**/${await get('ignorePrefix')}*.*`