-
Notifications
You must be signed in to change notification settings - Fork 9
/
vue.config.js
100 lines (93 loc) · 2.42 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
/**
* base config
* author: houjiazong <[email protected]>
* date: 2019/03/05
*/
const path = require('path')
const fs = require('fs')
const PROXY_TIMEOUT = 1000 * 60 * 2
const aliasSrcDir = ['api', 'assets', 'components', 'views', 'utils', 'styles', 'store', 'router', 'mixins', 'constants']
function resolve (dir) {
return path.join(__dirname, dir)
}
function fsExistsSync (path) {
try {
fs.accessSync(path, fs.F_OK)
} catch (e) {
return false
}
return true
}
const devServerCoustomConfig = fsExistsSync(resolve('./dev.server.config.js')) ? require('./dev.server.config.js') : {}
module.exports = {
publicPath: '/web-console/',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: true,
/**
* webpack config
* https://github.com/vuejs/vue-cli/blob/dev/docs/zh/guide/webpack.md
*/
chainWebpack: (config) => {
config
.plugin('define')
.tap((args) => {
args[0]['process.env'] = Object.assign(args[0]['process.env'], {
BUILD_TIME: JSON.stringify(`${+new Date()}`)
})
return args
})
},
configureWebpack: (config) => {
const aliasSrcDirConfig = {}
aliasSrcDir.forEach(item => {
aliasSrcDirConfig[`@${item}`] = resolve(`./src/${item}`)
})
Object.assign(config, {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': resolve('./src'),
'~': resolve('./src'),
'@@': resolve('.'),
'~~': resolve('.'),
...aliasSrcDirConfig
}
}
})
},
productionSourceMap: true,
parallel: require('os').cpus().length > 1,
/**
* 考虑到每个人的配置习惯不同,如有自定义 devServer 配置的需求请在根目录下创建 dev.server.config.js 文件
* 然后使用 module.exports 导出配置即可,请勿直接修改以下配置 !!
* dev.server.config.js 不进行 git 提交操作
*/
devServer: Object.assign({
// open: process.platform === 'darwin',
// host: '0.0.0.0',
port: 4000,
// public: '0.0.0.0:4000',
proxy: {
'/api': {
target: 'https://office.yunion.io/',
ws: true,
changeOrigin: true,
proxyTimeout: PROXY_TIMEOUT,
secure: false
}
}
}, devServerCoustomConfig),
// 第三方插件配置
pluginOptions: {
},
css: {
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true
}
}
}
}
}