-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
114 lines (108 loc) · 2.71 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const TerserPlugin = require('terser-webpack-plugin')
const BundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const { commitNumber, commitDate } = require('./scripts/version') // 打包时在 index.html meta 信息中记录版本号及日期
// webpack 插件
const webpackPlugins = []
if (process.env.ANALYZER) {
webpackPlugins.push(new BundleAnalyzer())
}
// webpack 打包优化插件
const minimizers = []
if (process.env.NODE_ENV === 'production') {
minimizers.push(new TerserPlugin({
terserOptions: {
ecma: 6,
compress: { drop_console: true },
output: { comments: false, beautify: false }
},
extractComments: false
}))
}
let webpackExternals = {}
if (process.env.NODE_ENV === 'production') {
webpackExternals = {
axios: 'axios',
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'element-ui': 'ELEMENT'
// 'vue-quill-editor': 'VueQuillEditor'
}
}
const path = require('path')
function resolve (dir) {
return path.join(__dirname, dir)
}
module.exports = {
publicPath: '',
outputDir: 'dist',
runtimeCompiler: true,
productionSourceMap: false,
configureWebpack: {
plugins: webpackPlugins,
resolve: {
alias: {
'@': resolve('src')
}
},
optimization: {
minimize: true,
minimizer: minimizers,
splitChunks: {
chunks: 'async',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 6,
maxInitialRequests: 4,
automaticNameDelimiter: '~',
automaticNameMaxLength: 30,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
externals: webpackExternals
},
chainWebpack: config => {
config.plugin('html').tap(args => {
args[0].meta = {
version: `${commitDate} ${commitNumber}`,
publish: `${new Date()}`
}
return args
})
},
devServer: {
proxy: {
'/api': {
target: `http://${process.env.VUE_APP_SUBDOMAIN}.welishi.cn`,
changeOrigin: true,
router: {
'localhost:8081': 'http://dev.internal.feel.ac.cn'
},
headers: {
Host: `${process.env.VUE_APP_SUBDOMAIN}.welishi.cn`
}
},
'/attachment': {
target: `http://${process.env.VUE_APP_SUBDOMAIN}.welishi.cn`,
changeOrigin: true,
router: {
'localhost:8081': 'http://dev.internal.feel.ac.cn'
},
headers: {
Host: `${process.env.VUE_APP_SUBDOMAIN}.welishi.cn`
}
}
}
}
}