-
Notifications
You must be signed in to change notification settings - Fork 7
/
vue.config.js
87 lines (79 loc) · 2.35 KB
/
vue.config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const webpack = require("webpack");
module.exports = {
lintOnSave: false,
configureWebpack: (config) => {
config.module.rules.push({
test: /\.js$/,
use: [{
loader: require.resolve('@open-wc/webpack-import-meta-loader'),
}]
});
config.module.rules.push({
test: /\.js$/,
use: [{
loader: require.resolve('babel-loader'),
}]
});
console.log(config.module.rules);
// js output config
config.output.filename = "[name].[hash].js";
config.output.chunkFilename = "[name].[hash].js";
config.optimization = {
splitChunks: {
cacheGroups: {
common: {
//抽取所有入口页面都需要的公共chunk
name: "chunk-common",
chunks: "initial",
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
priority: 1,
reuseExistingChunk: true,
enforce: true
}
}
}
};
},
chainWebpack: config => {
// 删除默认的splitChunk
config.optimization.delete("splitChunks");
// 用cdn方式引入
config.externals({
'vue': 'Vue',
'element-ui': 'ELEMENT',
'echarts': 'echarts',
'axios': 'axios',
});
config
.plugin("ignore")
.use(
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en$/)
);
if (process.env.use_analyzer) {
config
.plugin("webpack-bundle-analyzer").use(
require('webpack-bundle-analyzer').BundleAnalyzerPlugin
);
}
return config;
},
devServer: {
port: 10005,
hot: true,
},
parallel: false,
pages: {
embed: {
entry: 'src/embed/embed.main.js',
template: 'public/embed.html',
chunks: ["embed", "chunk-common"]
},
index: {
entry: 'src/main.js',
template: 'public/index.html',
chunks: ["index", "chunk-common"]
},
},
}