diff --git a/lib/core/src/server/__snapshots__/mergeConfigs.test.js.snap b/lib/core/src/server/__snapshots__/mergeConfigs.test.js.snap index b3a99e4f2f6..c33eda68bd0 100644 --- a/lib/core/src/server/__snapshots__/mergeConfigs.test.js.snap +++ b/lib/core/src/server/__snapshots__/mergeConfigs.test.js.snap @@ -12,6 +12,12 @@ Object { "r2", ], }, + "optimization": Object { + "runtimeChunk": true, + "splitChunks": Object { + "chunks": "all", + }, + }, "output": Object { "filename": "[name].js", }, @@ -48,6 +54,12 @@ Object { "r2", ], }, + "optimization": Object { + "runtimeChunk": true, + "splitChunks": Object { + "chunks": "all", + }, + }, "output": Object { "filename": "[name].js", }, @@ -84,6 +96,15 @@ Object { "r4", ], }, + "optimization": Object { + "minimizer": Array [ + "banana", + ], + "runtimeChunk": true, + "splitChunks": Object { + "chunks": "all", + }, + }, "output": Object { "filename": "[name].js", }, diff --git a/lib/core/src/server/mergeConfigs.js b/lib/core/src/server/mergeConfigs.js index 3bfa635d5b0..7b259cba86d 100644 --- a/lib/core/src/server/mergeConfigs.js +++ b/lib/core/src/server/mergeConfigs.js @@ -34,6 +34,16 @@ function resolve({ resolve: defaultResolve = {} }, { resolve: customResolve = {} }; } +function optimization( + { optimization: defaultOptimization = {} }, + { optimization: customOptimization = {} } +) { + return { + ...defaultOptimization, + ...customOptimization, + }; +} + function mergeConfigs(config, customConfig) { return { // We'll always load our configurations after the custom config. @@ -44,6 +54,7 @@ function mergeConfigs(config, customConfig) { plugins: plugins(config, customConfig), module: module(config, customConfig), resolve: resolve(config, customConfig), + optimization: optimization(config, customConfig), }; } diff --git a/lib/core/src/server/mergeConfigs.test.js b/lib/core/src/server/mergeConfigs.test.js index 0d3d4cff8b2..da2962bcb8e 100644 --- a/lib/core/src/server/mergeConfigs.test.js +++ b/lib/core/src/server/mergeConfigs.test.js @@ -20,6 +20,12 @@ const config = { A2: 'src/B2', }, }, + optimization: { + splitChunks: { + chunks: 'all', + }, + runtimeChunk: true, + }, }; describe('mergeConfigs', () => { @@ -45,6 +51,9 @@ describe('mergeConfigs', () => { A4: 'src/B4', }, }, + optimization: { + minimizer: ['banana'], + }, }; const result = mergeConfigs(config, customConfig);