fix(webpack): add standardWebpackConfigFunction option when users opts for a standard config function (#20702)
This commit is contained in:
parent
99ec7d81cc
commit
b527158ea3
@ -313,6 +313,11 @@
|
||||
"default": true,
|
||||
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 18. See https://nx.dev/recipes/webpack/webpack-config-setup."
|
||||
},
|
||||
"standardWebpackConfigFunction": {
|
||||
"type": "boolean",
|
||||
"description": "Set to true if the webpack config exports a standard webpack function, not an Nx-specific one. See: https://webpack.js.org/configuration/configuration-types/#exporting-a-function",
|
||||
"default": false
|
||||
},
|
||||
"extractLicenses": {
|
||||
"type": "boolean",
|
||||
"description": "Extract all licenses in a separate file, in the case of production builds only."
|
||||
|
||||
@ -81,7 +81,11 @@ export async function* devServerExecutor(
|
||||
|
||||
// Only add the dev server option if user is composable plugin.
|
||||
// Otherwise, user should define `devServer` option directly in their webpack config.
|
||||
if (isNxWebpackComposablePlugin(userDefinedWebpackConfig)) {
|
||||
if (
|
||||
typeof userDefinedWebpackConfig === 'function' &&
|
||||
isNxWebpackComposablePlugin(userDefinedWebpackConfig) &&
|
||||
!buildOptions.standardWebpackConfigFunction
|
||||
) {
|
||||
config = await userDefinedWebpackConfig(
|
||||
{ devServer },
|
||||
{
|
||||
|
||||
@ -50,6 +50,7 @@ export interface WebpackExecutorOptions {
|
||||
// TODO(v18): Remove this option
|
||||
/** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
|
||||
isolatedConfig?: boolean;
|
||||
standardWebpackConfigFunction?: boolean;
|
||||
main?: string;
|
||||
memoryLimit?: number;
|
||||
namedChunks?: boolean;
|
||||
|
||||
@ -237,6 +237,11 @@
|
||||
"default": true,
|
||||
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 18. See https://nx.dev/recipes/webpack/webpack-config-setup."
|
||||
},
|
||||
"standardWebpackConfigFunction": {
|
||||
"type": "boolean",
|
||||
"description": "Set to true if the webpack config exports a standard webpack function, not an Nx-specific one. See: https://webpack.js.org/configuration/configuration-types/#exporting-a-function",
|
||||
"default": false
|
||||
},
|
||||
"extractLicenses": {
|
||||
"type": "boolean",
|
||||
"description": "Extract all licenses in a separate file, in the case of production builds only."
|
||||
|
||||
@ -58,7 +58,11 @@ async function getWebpackConfigs(
|
||||
? composePluginsSync(withNx(options), withWeb(options))
|
||||
: withNx(options))({}, { options, context });
|
||||
|
||||
if (isNxWebpackComposablePlugin(userDefinedWebpackConfig)) {
|
||||
if (
|
||||
typeof userDefinedWebpackConfig === 'function' &&
|
||||
isNxWebpackComposablePlugin(userDefinedWebpackConfig) &&
|
||||
!options.standardWebpackConfigFunction
|
||||
) {
|
||||
// Old behavior, call the Nx-specific webpack config function that user exports
|
||||
return await userDefinedWebpackConfig(config, {
|
||||
options,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user