-
Notifications
You must be signed in to change notification settings - Fork 64
/
vue.config.js
37 lines (35 loc) · 972 Bytes
/
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
const IS_PROD = process.env.NODE_ENV === 'production';
const cdn = {
externals: {
vue: 'Vue',
'element-plus': 'ElementPlus',
AMap: 'AMap'
},
css: ['https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css'],
js: [
'https://unpkg.com/vue@3.2.26/dist/vue.global.js',
'https://unpkg.com/element-plus@1.3.0-beta.5/dist/index.full.min.js'
]
};
module.exports = {
publicPath: IS_PROD ? '././' : '/', // 打包相对路径
productionSourceMap: false,
lintOnSave: true,
runtimeCompiler: true,
chainWebpack: config => {
// ============注入cdn start============
config.plugin('html').tap(args => {
// 生产环境或本地需要cdn时,才注入cdn
if (IS_PROD) args[0].cdn = cdn;
return args;
});
// ============注入cdn start============
},
configureWebpack: config => {
// 生产环境相关配置
if (IS_PROD) {
// cdn
config.externals = cdn.externals;
}
}
};