1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = mergeWebpackConfig;
|
5 |
|
6 | var _webpackMerge = _interopRequireDefault(require("webpack-merge"));
|
7 |
|
8 | var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
|
9 |
|
10 | var _omit = _interopRequireDefault(require("lodash/omit"));
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 |
|
14 | const IGNORE_SECTIONS = ['entry', 'externals', 'output', 'watch', 'stats', 'styleguidist'];
|
15 | const IGNORE_SECTIONS_ENV = {
|
16 | development: [],
|
17 |
|
18 |
|
19 | production: ['devtool']
|
20 | };
|
21 | const IGNORE_PLUGINS = ['CommonsChunkPlugins', 'MiniHtmlWebpackPlugin', 'HtmlWebpackPlugin', 'OccurrenceOrderPlugin', 'DedupePlugin', 'UglifyJsPlugin', 'TerserPlugin', 'HotModuleReplacementPlugin'];
|
22 | const merge = (0, _webpackMerge.default)({
|
23 |
|
24 | customizeArray: _webpackMerge.default.unique('plugins', IGNORE_PLUGINS, plugin => plugin.constructor && plugin.constructor.name)
|
25 | });
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function mergeWebpackConfig(baseConfig, userConfig, env = 'production') {
|
40 | const userConfigObject = (0, _isFunction.default)(userConfig) ? userConfig(env) : userConfig;
|
41 | const safeUserConfig = (0, _omit.default)(userConfigObject, IGNORE_SECTIONS.concat(IGNORE_SECTIONS_ENV[env]));
|
42 | return merge(baseConfig, safeUserConfig);
|
43 | } |
\ | No newline at end of file |