-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.biz.analyze.js
45 lines (43 loc) · 1.31 KB
/
webpack.biz.analyze.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* 项目包大小及组成分析环境
*/
// webpack 包大小及组成分析插件
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// 依赖生产环境配置
const generateBuildConfig = require('./webpack.build.js');
module.exports = function (env) {
const config = generateBuildConfig(env);
return {
...config,
resolve: {
...config.resolve,
// 直接通过编译 bizcharts/es 进行打包体积优化
alias: {
'bizcharts':'bizcharts/es'
}
},
module: {
rules: config.module.rules.concat([
// 通过 include 指定需要优化编译的包 bizcharts
{
test: /\.js$/,
include:
/(node_modules\/bizcharts\/es)/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
]
}
])
},
plugins: config.plugins.concat([
// 添加包大小及组成分析插件
new BundleAnalyzerPlugin()
])
};
};