Merge pull request #4121 from WearyMonkey/toby-merge-optimisations

Merge optimisation configs
This commit is contained in:
Filipp Riabchun 2018-09-08 19:57:59 +02:00 committed by GitHub
commit 87572f70e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

@ -12,6 +12,12 @@ Object {
"r2", "r2",
], ],
}, },
"optimization": Object {
"runtimeChunk": true,
"splitChunks": Object {
"chunks": "all",
},
},
"output": Object { "output": Object {
"filename": "[name].js", "filename": "[name].js",
}, },
@ -48,6 +54,12 @@ Object {
"r2", "r2",
], ],
}, },
"optimization": Object {
"runtimeChunk": true,
"splitChunks": Object {
"chunks": "all",
},
},
"output": Object { "output": Object {
"filename": "[name].js", "filename": "[name].js",
}, },
@ -84,6 +96,15 @@ Object {
"r4", "r4",
], ],
}, },
"optimization": Object {
"minimizer": Array [
"banana",
],
"runtimeChunk": true,
"splitChunks": Object {
"chunks": "all",
},
},
"output": Object { "output": Object {
"filename": "[name].js", "filename": "[name].js",
}, },

View File

@ -34,6 +34,16 @@ function resolve({ resolve: defaultResolve = {} }, { resolve: customResolve = {}
}; };
} }
function optimization(
{ optimization: defaultOptimization = {} },
{ optimization: customOptimization = {} }
) {
return {
...defaultOptimization,
...customOptimization,
};
}
function mergeConfigs(config, customConfig) { function mergeConfigs(config, customConfig) {
return { return {
// We'll always load our configurations after the custom config. // We'll always load our configurations after the custom config.
@ -44,6 +54,7 @@ function mergeConfigs(config, customConfig) {
plugins: plugins(config, customConfig), plugins: plugins(config, customConfig),
module: module(config, customConfig), module: module(config, customConfig),
resolve: resolve(config, customConfig), resolve: resolve(config, customConfig),
optimization: optimization(config, customConfig),
}; };
} }

View File

@ -20,6 +20,12 @@ const config = {
A2: 'src/B2', A2: 'src/B2',
}, },
}, },
optimization: {
splitChunks: {
chunks: 'all',
},
runtimeChunk: true,
},
}; };
describe('mergeConfigs', () => { describe('mergeConfigs', () => {
@ -45,6 +51,9 @@ describe('mergeConfigs', () => {
A4: 'src/B4', A4: 'src/B4',
}, },
}, },
optimization: {
minimizer: ['banana'],
},
}; };
const result = mergeConfigs(config, customConfig); const result = mergeConfigs(config, customConfig);