-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvue.config.js
62 lines (52 loc) · 1.24 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
/** @format */
const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
function resolve(dir) {
return path.join(__dirname, dir);
}
const file = process.env.VUE_APP_FILE;
const buildConf = {
devServer: {
overlay: {
warnings: true,
errors: true,
},
},
productionSourceMap: false,
outputDir: file,
configureWebpack: (config) => {
// 自动修复语法错误
Object.assign(
config.module.rules[config.module.rules.length - 3].use[0].options,
{
fix: true,
},
);
// 优化体积
if (isProduction) {
config.externals = {
lodash: 'lodash',
moment: 'moment',
vue: 'Vue',
};
}
},
chainWebpack: (config) => {
config.resolve.alias.set('assets', resolve('src/assets'));
// 解决 wc-async 打包之后引入路径问题
if (file === 'dist') {
config.resolve.alias.set('~root', resolve(file));
}
config.plugin('StyleLintPlugin').use(StyleLintPlugin, [
{
fix: true,
},
]);
return config;
},
};
if (file === 'site') {
buildConf.publicPath = process.env.VUE_APP_CDN;
}
module.exports = buildConf;