-
Notifications
You must be signed in to change notification settings - Fork 6
/
vue.config.js
64 lines (59 loc) · 1.54 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
// uni-simple-router
const TransformPages = require('uni-read-pages')
const { webpack } = new TransformPages()
const ENV = require('./src/config/env.' + process.env.NODE_ENV)
// 获取路径
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
transpileDependencies: ['luch-request'],
// 启用压缩代码
configureWebpack: () => {
return {
// 配置 alias 路径别名
resolve: {
alias: {
'@': resolve('src')
}
},
optimization: {
minimize: ENV.UNI_COMPRESSION_CODE
},
// 插件
plugins: [
// 配置 uni-simple-router 路由插件
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'meta', 'aliasPath']
})
return JSON.stringify(tfPages.routes)
}, true)
})
]
}
},
chainWebpack: (config) => {
config.optimization.minimizer('terser').tap((args) => {
const compress = args[0].terserOptions.compress
compress.drop_console = ENV.DROP_CONSOLE
compress.pure_funcs = ['__f__']
return args
})
},
// 服务代理
devServer: {
proxy: {
[ENV.UNI_PROXY_PREFIX]: {
target: ENV.UNI_REQUEST_TYPE ? ENV.UNI_API_URL : ENV.UNI_API_IP_URL,
changeOrigin: true,
ws: true,
pathRewrite: {
[`^${ENV.UNI_PROXY_PREFIX}`]: ENV.UNI_PROXY_PREFIX
}
}
}
}
}