diff --git a/docs/generated/packages/node.json b/docs/generated/packages/node.json index 3c297c0f63..cf82cfee8e 100644 --- a/docs/generated/packages/node.json +++ b/docs/generated/packages/node.json @@ -302,6 +302,22 @@ "description": "Run build when files change.", "default": false }, + "watchOptions": { + "type": "object", + "description": "A set of options used to customize watch mode.", + "properties": { + "aggregateTimeout": { "type": "integer" }, + "ignored": { + "oneOf": [ + { "type": "array", "items": { "type": "string" } }, + { "type": "string" } + ] + }, + "poll": { "type": "integer" }, + "followSymlinks": { "type": "boolean" }, + "stdin": { "type": "boolean" } + } + }, "poll": { "type": "number", "description": "Frequency of file watcher in ms." diff --git a/packages/node/src/executors/webpack/schema.json b/packages/node/src/executors/webpack/schema.json index 923723cec9..60b733357b 100644 --- a/packages/node/src/executors/webpack/schema.json +++ b/packages/node/src/executors/webpack/schema.json @@ -26,6 +26,37 @@ "description": "Run build when files change.", "default": false }, + "watchOptions": { + "type": "object", + "description": "A set of options used to customize watch mode.", + "properties": { + "aggregateTimeout": { + "type": "integer" + }, + "ignored": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "poll": { + "type": "integer" + }, + "followSymlinks": { + "type": "boolean" + }, + "stdin": { + "type": "boolean" + } + } + }, "poll": { "type": "number", "description": "Frequency of file watcher in ms." diff --git a/packages/node/src/executors/webpack/webpack.impl.spec.ts b/packages/node/src/executors/webpack/webpack.impl.spec.ts index bf4ee4ca3a..7dc9f92126 100644 --- a/packages/node/src/executors/webpack/webpack.impl.spec.ts +++ b/packages/node/src/executors/webpack/webpack.impl.spec.ts @@ -84,6 +84,27 @@ describe('Node Build Executor', () => { ); }); + it('should use watchOptions if passed in', async () => { + await webpackExecutor( + { + ...options, + watchOptions: { + ignored: ['path1'], + }, + }, + context + ).next(); + + expect(runWebpack).toHaveBeenCalledWith( + expect.objectContaining({ + watchOptions: { + ignored: ['path1'], + aggregateTimeout: 200, + }, + }) + ); + }); + describe('webpackConfig', () => { it('should handle custom path', async () => { jest.mock( diff --git a/packages/node/src/utils/config.ts b/packages/node/src/utils/config.ts index 11d01f0629..71a428beba 100644 --- a/packages/node/src/utils/config.ts +++ b/packages/node/src/utils/config.ts @@ -113,6 +113,7 @@ export function getBaseWebpackPartial( // two builds on a single file change. aggregateTimeout: 200, poll: options.poll, + ...options.watchOptions, }, stats: getStatsConfig(options), experiments: { diff --git a/packages/node/src/utils/types.ts b/packages/node/src/utils/types.ts index cd51238ca7..a7c98b3a60 100644 --- a/packages/node/src/utils/types.ts +++ b/packages/node/src/utils/types.ts @@ -59,11 +59,20 @@ export interface AdditionalEntryPoint { entryPath: string; } +export interface WebpackWatchOptions { + aggregateTimeout?: number; + ignored?: Array | string; + poll?: number; + followSymlinks?: boolean; + stdin?: boolean; +} + export interface BuildBuilderOptions { main: string; outputPath: string; tsConfig: string; watch?: boolean; + watchOptions?: WebpackWatchOptions; sourceMap?: boolean | SourceMapOptions; optimization?: boolean | OptimizationOptions; maxWorkers?: number;