diff --git a/packages/angular_devkit/build_angular/src/builders/application/build-action.ts b/packages/angular_devkit/build_angular/src/builders/application/build-action.ts index d72906747e75..7e285e8d5ab3 100644 --- a/packages/angular_devkit/build_angular/src/builders/application/build-action.ts +++ b/packages/angular_devkit/build_angular/src/builders/application/build-action.ts @@ -77,21 +77,27 @@ export async function* runEsBuildBuildAction( logger.info('Watch mode enabled. Watching for file changes...'); } + const ignored: string[] = [ + // Ignore the output and cache paths to avoid infinite rebuild cycles + outputPath, + cacheOptions.basePath, + `${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`, + ]; + + if (!preserveSymlinks) { + // Ignore all node modules directories to avoid excessive file watchers. + // Package changes are handled below by watching manifest and lock files. + // NOTE: this is not enable when preserveSymlinks is true as this would break `npm link` usages. + ignored.push('**/node_modules/**'); + } + // Setup a watcher const { createWatcher } = await import('../../tools/esbuild/watcher'); watcher = createWatcher({ polling: typeof poll === 'number', interval: poll, followSymlinks: preserveSymlinks, - ignored: [ - // Ignore the output and cache paths to avoid infinite rebuild cycles - outputPath, - cacheOptions.basePath, - // Ignore all node modules directories to avoid excessive file watchers. - // Package changes are handled below by watching manifest and lock files. - '**/node_modules/**', - `${workspaceRoot.replace(/\\/g, '/')}/**/.*/**`, - ], + ignored, }); // Setup abort support