From 6ee865e003a5822f0ad792013945bce535f5b83c Mon Sep 17 00:00:00 2001 From: Phillip Lanclos Date: Tue, 17 Jan 2023 10:03:52 -0600 Subject: [PATCH] fix(webpack): fix optimization can't be turned off --- packages/webpack/src/utils/with-nx.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/webpack/src/utils/with-nx.ts b/packages/webpack/src/utils/with-nx.ts index f421a0209060f..4728f3df6031e 100644 --- a/packages/webpack/src/utils/with-nx.ts +++ b/packages/webpack/src/utils/with-nx.ts @@ -39,6 +39,11 @@ export function withNx(opts?: { skipTypeChecking?: boolean }) { const plugins: WebpackPluginInstance[] = []; + const scriptsOptimization = + typeof options.optimization === 'object' + ? options.optimization.scripts + : options.optimization; + if (!opts?.skipTypeChecking) { plugins.push( new ForkTsCheckerWebpackPlugin({ @@ -185,7 +190,7 @@ export function withNx(opts?: { skipTypeChecking?: boolean }) { optimization: { ...config.optimization, sideEffects: true, - minimize: !!options.optimization, + minimize: scriptsOptimization, minimizer: [ options.compiler !== 'swc' ? new TerserPlugin({