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
This commit is contained in:
Samuel Attard authored and GitHub committed 2026-09-14 20:22:04 +02:00
1 parent a36f9cd12a
commit 59f0330233
1 file changed
+12 -2
+12 -2
View File
@@ -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: {