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,
|
"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."
|
"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": {
|
"extractLicenses": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Extract all licenses in a separate file, in the case of production builds only."
|
"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.
|
// Only add the dev server option if user is composable plugin.
|
||||||
// Otherwise, user should define `devServer` option directly in their webpack config.
|
// 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(
|
config = await userDefinedWebpackConfig(
|
||||||
{ devServer },
|
{ devServer },
|
||||||
{
|
{
|
||||||
|
|||||||
@ -50,6 +50,7 @@ export interface WebpackExecutorOptions {
|
|||||||
// TODO(v18): Remove this option
|
// 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) */
|
/** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
|
||||||
isolatedConfig?: boolean;
|
isolatedConfig?: boolean;
|
||||||
|
standardWebpackConfigFunction?: boolean;
|
||||||
main?: string;
|
main?: string;
|
||||||
memoryLimit?: number;
|
memoryLimit?: number;
|
||||||
namedChunks?: boolean;
|
namedChunks?: boolean;
|
||||||
|
|||||||
@ -237,6 +237,11 @@
|
|||||||
"default": true,
|
"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."
|
"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": {
|
"extractLicenses": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Extract all licenses in a separate file, in the case of production builds only."
|
"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))
|
? composePluginsSync(withNx(options), withWeb(options))
|
||||||
: withNx(options))({}, { options, context });
|
: 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
|
// Old behavior, call the Nx-specific webpack config function that user exports
|
||||||
return await userDefinedWebpackConfig(config, {
|
return await userDefinedWebpackConfig(config, {
|
||||||
options,
|
options,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user