1 Star 0 Fork 0

animalcoder/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Optimization.js 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
animalcoder 提交于 2020-03-23 09:59 +08:00 . Vue6
const ChainedMap = require('./ChainedMap');
const Plugin = require('./Plugin');
module.exports = class extends ChainedMap {
constructor(parent) {
super(parent);
this.minimizers = new ChainedMap(this);
this.extend([
'concatenateModules',
'flagIncludedChunks',
'mergeDuplicateChunks',
'minimize',
'namedChunks',
'namedModules',
'nodeEnv',
'noEmitOnErrors',
'occurrenceOrder',
'portableRecords',
'providedExports',
'removeAvailableModules',
'removeEmptyChunks',
'runtimeChunk',
'sideEffects',
'splitChunks',
'usedExports',
]);
}
minimizer(name) {
if (Array.isArray(name)) {
throw new Error(
'optimization.minimizer() no longer supports being passed an array. ' +
'Either switch to the new syntax (https://github.com/neutrinojs/webpack-chain#config-optimization-minimizers-adding) or downgrade to webpack-chain 4. ' +
'If using Vue this likely means a Vue plugin has not yet been updated to support Vue CLI 4+.',
);
}
return this.minimizers.getOrCompute(
name,
() => new Plugin(this, name, 'optimization.minimizer'),
);
}
toConfig() {
return this.clean(
Object.assign(this.entries() || {}, {
minimizer: this.minimizers.values().map(plugin => plugin.toConfig()),
}),
);
}
merge(obj, omit = []) {
if (!omit.includes('minimizer') && 'minimizer' in obj) {
Object.keys(obj.minimizer).forEach(name =>
this.minimizer(name).merge(obj.minimizer[name]),
);
}
return super.merge(obj, [...omit, 'minimizer']);
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/animalcoder/Vue.git
git@gitee.com:animalcoder/Vue.git
animalcoder
Vue
Vue
master

搜索帮助