/
vue.config.js
69 lines (67 loc) · 2.25 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
const path = require('path');
const PORT = 9002;
// const PROXY_SERVER = '';
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/vue-admin-elementUI/' : '/',
lintOnSave: true,
chainWebpack: config => {
config.showEslintErrorsInOverlay = true;
config.resolve.alias
.set('@', resolve('src'))
.set('@views', resolve('src/views'))
.set('@api', resolve('src/api'))
.set('@utils', resolve('src/utils'))
.set('@common', resolve('src/common'))
.set('@style', resolve('src/assets/style'))
.set('@images', resolve('src/assets/images'));
},
productionSourceMap: false, // 生产打包时不输出map文件,增加打包速度
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false;
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true;
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = [
'console.log'
];
config.optimization.splitChunks.cacheGroups.commons = {
test: /[\\/]node_modules[\\/](element-ui)[\\/]/,
name: 'element-ui',
chunks: 'all'
};
}
},
pluginOptions: {},
devServer: {
overlay: {
warnings: true,
errors: true
},
disableHostCheck: true,
open: false,
port: PORT,
host: '0.0.0.0',
after: function(app, server) {
setTimeout(() => {
require('child_process').exec(`start http://localhost:${PORT}`);
}, 2000);
}
// ,
// proxy: {
// '/proxyApi': {
// target: PROXY_SERVER,
// changeOrigin: true,
// pathRewrite: {
// '^/proxyApi': '/'
// }
// }
// }
},
// Vue-ECharts 默认在 webpack 环境下会引入未编译的源码版本,
// 如果你正在使用官方的 Vue CLI 来创建项目,
// 可能会遇到默认配置把 node_modules 中的文件排除在 Babel 转译范围以外的问题。请按如下方法修改配置
transpileDependencies: ['vue-echarts', 'resize-detector']
};