vue-cli3 webpack配置
配置一:report
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV);
module.exports = {
chainWebpack: config => {
// 打包分析
if (IS_PROD) {
config.plugin("webpack-report").use(BundleAnalyzerPlugin, [
{
analyzerMode: "static"
}
]);
}
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
配置二:externals
module.exports = {
configureWebpack: {
externals: {
'mxgraph': 'mxgraph'
}
}
}
1
2
3
4
5
6
7
2
3
4
5
6
7
配置三:alias
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@': resolve('src'),
static: resolve('public/static')
}
},
}
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10