-
Notifications
You must be signed in to change notification settings - Fork 10
/
vue.config.js
72 lines (67 loc) · 1.67 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
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const mock = require('./script/mock.json')
const config = require('./script/config.json')
const { NODE_ENV, VUE_APP_BUILD_ENV = 'base' } = process.env
const before = (app) => {
// 开发环境下可以使用 mock 数据
if (NODE_ENV === 'development' && mock) {
const { api } = mock
api.forEach((item) => {
app.get(`/api/v4${item.url}`, (req, res) => {
res.json(item.data)
})
})
}
}
const customConfig = {
...config.base,
...(config[VUE_APP_BUILD_ENV] || {}),
}
const getVersion = () => {
const matched = process.env.npm_package_version.match(/^\d\.\d/)
return matched ? `v${matched[0]}` : 'latest'
}
process.env.VUE_APP_VERSION = getVersion()
module.exports = {
devServer: {
port: 3001,
disableHostCheck: true,
before,
proxy: {
'/api': {
target: process.env.HOST_URL || 'http://127.0.0.1:18083',
changeOrigin: true,
},
'/dashboard': {
target: process.env.HOST_URL || 'http://127.0.0.1:18083/api/v4',
changeOrigin: true,
pathRewrite: {
'/dashboard': '',
},
},
},
},
css: {
loaderOptions: {
less: {
modifyVars: {
'primary-color': '#34C388',
'link-color': '#34C388',
},
javascriptEnabled: true,
},
},
},
assetsDir: 'static',
publicPath: customConfig.publicPath,
productionSourceMap: false,
configureWebpack: {
plugins: [
new MonacoWebpackPlugin({
output: 'static/',
languages: ['json', 'sql', 'plaintext', 'avro', 'protobuf'],
features: ['!gotoSymbol'],
}),
],
},
}