Skip to content

Commit

Permalink
fix: dll missing uglifyJs config
Browse files Browse the repository at this point in the history
  • Loading branch information
hubcarl committed Nov 22, 2018
1 parent 6acfaf8 commit 34a5b4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ exports.base = {
},
node: {
console: false,
process: false,
Buffer: false,
setImmediate: false
}
Expand Down
5 changes: 5 additions & 0 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ exports.getDllWebpackConfig = (config, option = {}) => {
if (cli.size) {
plugins.push(cli.size === true ? { analyzer: true } : { stats: true });
}
// need dll customize uglifyJs config
const uglifyJs = utils.getConfigPlugin(config.plugins, 'uglifyJs');
if (uglifyJs) {
plugins.push({ uglifyJs });
}
dll.forEach(item => {
const tmpConfig = utils.cloneDeep(config);
const dllConfig = merge(tmpConfig, { entry: null, dll: null, plugins }, { dll: item }, item.webpackConfig);
Expand Down
9 changes: 1 addition & 8 deletions lib/core/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ const chalk = require('chalk');
module.exports = {

getConfigPlugin(label) {
const plugins = this.config.plugins || {};
if (Array.isArray(plugins)) {
const plugin = plugins.find(item => {
return item.hasOwnProperty(label);
});
return plugin && plugin[label];
}
return plugins[label];
return this.utils.getConfigPlugin(this.config.plugins, label);
},

getPluginByName(label) {
Expand Down
10 changes: 10 additions & 0 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,14 @@ utils.getPluginLabel = plugin => {
return md5(plugin.apply.toString());
};

utils.getConfigPlugin = (plugins = {}, label) => {
if (Array.isArray(plugins)) {
const plugin = plugins.find(item => {
return item.hasOwnProperty(label);
});
return plugin && plugin[label];
}
return plugins[label];
};

module.exports = utils;

0 comments on commit 34a5b4a

Please sign in to comment.