diff --git a/docs/generated/packages/webpack/executors/webpack.json b/docs/generated/packages/webpack/executors/webpack.json index 91106a199457a..f1fc66bdf12d9 100644 --- a/docs/generated/packages/webpack/executors/webpack.json +++ b/docs/generated/packages/webpack/executors/webpack.json @@ -43,7 +43,7 @@ "type": "string", "alias": "platform", "description": "Target platform for the build, same as the Webpack target option.", - "enum": ["node", "web"], + "enum": ["node", "web", "webworker"], "default": "web" }, "deleteOutputPath": { diff --git a/docs/generated/packages/webpack/generators/webpack-project.json b/docs/generated/packages/webpack/generators/webpack-project.json index 8c0b692df7631..d616f40f7784a 100644 --- a/docs/generated/packages/webpack/generators/webpack-project.json +++ b/docs/generated/packages/webpack/generators/webpack-project.json @@ -36,7 +36,7 @@ "target": { "type": "string", "description": "Target platform for the build, same as the Webpack config option.", - "enum": ["node", "web"], + "enum": ["node", "web", "webworker"], "default": "web" }, "skipFormat": { diff --git a/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts b/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts index f6a8e06ff1b2b..bf1e4cca41247 100644 --- a/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts +++ b/packages/webpack/src/executors/webpack/lib/get-webpack-config.ts @@ -20,8 +20,8 @@ export function getWebpackConfig( ): Configuration { const config: Configuration = {}; const configure = - options.target === 'node' - ? withNx() - : composePluginsSync(withNx(), withWeb()); + options.target === 'web' + ? composePluginsSync(withNx(), withWeb()) + : withNx(); return configure(config, { options, context }); } diff --git a/packages/webpack/src/executors/webpack/schema.d.ts b/packages/webpack/src/executors/webpack/schema.d.ts index fb05f82ff2959..461adc0164f88 100644 --- a/packages/webpack/src/executors/webpack/schema.d.ts +++ b/packages/webpack/src/executors/webpack/schema.d.ts @@ -61,7 +61,7 @@ export interface WebpackExecutorOptions { runtimeChunk?: boolean; sourceMap?: boolean | 'hidden'; statsJson?: boolean; - target?: 'node' | 'web'; + target?: 'node' | 'web' | 'webworker'; transformers?: TransformerEntry[]; tsConfig: string; vendorChunk?: boolean; diff --git a/packages/webpack/src/executors/webpack/schema.json b/packages/webpack/src/executors/webpack/schema.json index 1776f4e31a681..befe0e7e5960f 100644 --- a/packages/webpack/src/executors/webpack/schema.json +++ b/packages/webpack/src/executors/webpack/schema.json @@ -40,7 +40,7 @@ "type": "string", "alias": "platform", "description": "Target platform for the build, same as the Webpack target option.", - "enum": ["node", "web"], + "enum": ["node", "web", "webworker"], "default": "web" }, "deleteOutputPath": { diff --git a/packages/webpack/src/generators/webpack-project/schema.d.ts b/packages/webpack/src/generators/webpack-project/schema.d.ts index 98ed595ea4a9c..950a85f4aa541 100644 --- a/packages/webpack/src/generators/webpack-project/schema.d.ts +++ b/packages/webpack/src/generators/webpack-project/schema.d.ts @@ -7,7 +7,7 @@ export interface WebpackProjectGeneratorSchema { skipFormat?: boolean; skipPackageJson?: boolean; skipValidation?: boolean; - target?: 'node' | 'web'; + target?: 'node' | 'web' | 'webworker'; webpackConfig?: string; babelConfig?: string; } diff --git a/packages/webpack/src/generators/webpack-project/schema.json b/packages/webpack/src/generators/webpack-project/schema.json index 677d0a12d93c1..975adec259236 100644 --- a/packages/webpack/src/generators/webpack-project/schema.json +++ b/packages/webpack/src/generators/webpack-project/schema.json @@ -36,7 +36,7 @@ "target": { "type": "string", "description": "Target platform for the build, same as the Webpack config option.", - "enum": ["node", "web"], + "enum": ["node", "web", "webworker"], "default": "web" }, "skipFormat": { diff --git a/packages/webpack/src/generators/webpack-project/webpack-project.ts b/packages/webpack/src/generators/webpack-project/webpack-project.ts index d01de302db53d..5c3a81a64ec67 100644 --- a/packages/webpack/src/generators/webpack-project/webpack-project.ts +++ b/packages/webpack/src/generators/webpack-project/webpack-project.ts @@ -75,14 +75,14 @@ function addBuildTarget(tree: Tree, options: WebpackProjectGeneratorSchema) { buildOptions.babelUpwardRootMode = true; } - if (options.target === 'node') { + if (options.target === 'web') { tree.write( joinPathFragments(project.root, 'webpack.config.js'), ` -const { composePlugins, withNx } = require('@nx/webpack'); +const { composePlugins, withNx, withWeb } = require('@nx/webpack'); // Nx plugins for webpack. -module.exports = composePlugins(withNx(), (config) => { +module.exports = composePlugins(withNx(), withWeb(), (config) => { // Update the webpack config as needed here. // e.g. \`config.plugins.push(new MyPlugin())\` return config; @@ -93,10 +93,10 @@ module.exports = composePlugins(withNx(), (config) => { tree.write( joinPathFragments(project.root, 'webpack.config.js'), ` -const { composePlugins, withNx, withWeb } = require('@nx/webpack'); +const { composePlugins, withNx } = require('@nx/webpack'); // Nx plugins for webpack. -module.exports = composePlugins(withNx(), withWeb(), (config) => { +module.exports = composePlugins(withNx(), (config) => { // Update the webpack config as needed here. // e.g. \`config.plugins.push(new MyPlugin())\` return config;