From 59f0330233e78747cd54f5faa9f07742aab0b54c Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 14 Sep 2026 11:22:04 -0700 Subject: [PATCH] build: run webpack in production mode, minify only release bundles (#53856) * build: use webpack production mode for release bundles Release builds only enabled the minimizer; production mode adds numeric module ids, scope hoisting and unused-export removal (5-15% smaller js2c bundles). process.env.NODE_ENV is left untouched. * build: run webpack in production mode for all builds, minify only releases --- build/webpack/webpack.config.base.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build/webpack/webpack.config.base.js b/build/webpack/webpack.config.base.js index 21d1381219..c483124653 100644 --- a/build/webpack/webpack.config.base.js +++ b/build/webpack/webpack.config.base.js @@ -131,8 +131,14 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in ); } + // GN passes mode=production for official builds; that only decides + // whether the output is minified. webpack itself always runs in + // production mode (deterministic module ids, scope hoisting, unused-export + // removal) so testing builds exercise the same module graph as releases. + const minimize = env.mode === 'production'; + return { - mode: 'development', + mode: 'production', devtool: false, entry, target: alwaysHasNode ? 'node' : 'web', @@ -179,8 +185,12 @@ if ((globalThis.process || binding.process).argv.includes("--profile-electron-in __dirname: false, __filename: false }, + performance: { hints: false }, optimization: { - minimize: env.mode === 'production', + minimize, + // These bundles are Electron's own runtime; leave the app's + // process.env.NODE_ENV alone. + nodeEnv: false, minimizer: [ new TerserPlugin({ terserOptions: {