Skip to content

Commit

Permalink
build: 优化打包体积 (#1323)
Browse files Browse the repository at this point in the history
* 移除生产环境不必要的 map 文件
* webpack 添加 LimitChunkCountPlugin 用以解决 chunk 包太多的问题
  • Loading branch information
PrintNow authored Feb 23, 2022
1 parent 91b4e08 commit 76b3584
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const webpack = require('webpack');
const path = require('path');
function resolve(dir) {
return path.join(__dirname, dir);
}

module.exports = {
// 生产环境打包不输出 map
productionSourceMap: false,
devServer: {
disableHostCheck: true,
port: process.env.DEV_SERVER_PORT || 8080,
Expand Down Expand Up @@ -53,6 +56,13 @@ module.exports = {
symbolId: 'icon-[name]',
})
.end();
// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
{
maxChunks: 3,
minChunkSize: 10_000,
},
]);
},
// 添加插件的配置
pluginOptions: {
Expand Down

0 comments on commit 76b3584

Please sign in to comment.