-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvue.config.js
145 lines (141 loc) · 4.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const path = require('path')
require('events').EventEmitter.defaultMaxListeners = 0
// 解决内存溢出问题 MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
// 11 upgrade listeners added. Use emitter.setMaxListeners() to increase limit
const TransformPages = require('uni-read-pages') // 配置uni-router的路由页面
const tfPages = new TransformPages({
includes: ['path', 'name', 'meta']
})
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
publicPath: './', // 部署应用包时的基本 URL
transpileDependencies: ['uni-simple-router'],
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true // 生产环境不输出日志
} else { // 开发环境配置
// new vConsolePlugin({
// filter: [],
// enable: envType
// })
}
},
// 配置没有export导出的js
chainWebpack: config => {
config.module
.rule('zepto')
.test(require.resolve('./src/common/js/utils/zepto.min.js'))
.use('exports')
.loader('exports-loader?window.zepto')
.end()
.use('script')
.loader('script-loader')
.end()
config.module.rule('tvp')
.test(require.resolve('./src/common/js/utils/tvp.js'))
.use('exports')
.loader('exports-loader?window.tvp')
.end()
.use('script')
.loader('script-loader')
.end()
config.plugin('env')
.use(require.resolve('webpack/lib/ProvidePlugin'), [{$: 'zepto'}])
// 配置快捷访问文件夹
config.resolve.alias
.set('@', resolve('src'))
.set('zj', resolve('src/components'))
.set('mioJs', resolve('src/common/js'))
.set('json', resolve('src/static/mockJson'))
// 配置uni-router
config.plugin('provide').use(tfPages.webpack.DefinePlugin, [{
ROUTES: JSON.stringify(tfPages.routes)
}])
},
devServer: { // 开发环境跨域处理
proxy: {
'/api': {
target: 'http://www.okzyw.com',
changeOrigin: true, // 是否跨域
pathRewrite: {
'^/api': ''
}
},
'/foo': {
target: 'https://api.apiopen.top',
changeOrigin: true, // 是否跨域
pathRewrite: {
'^/foo': ''
}
},
'/db': {
// target: "http://10.19.193.135:8870/ssyth",
target: 'https://movie.douban.com',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/db': ''
}
},
'/mv': {
target: 'http://123.0t038.cn/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/mv': ''
}
},
'/lz': {
// target: "http://10.19.193.135:8870/ssyth",
target: 'http://api.lezhuan2020.cn/api',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/lz': ''
}
},
'/wx': {
target: 'https://mp.weixin.qq.com/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/wx': ''
}
},
'/ks': {
target: 'https://v.kuaishou.com/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/ks': ''
}
},
'/ym': {
target: 'http://luodi10424.1.0t038.cn/jin-61/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/ym': ''
}
},
'/dy': {
target: 'https://v.douyin.com/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/dy': ''
}
},
'/wxv': {
target: 'http://api-xcx.idoujia.cn/',
changeOrigin: true, // 是否跨域
ws: true,
pathRewrite: {
'^/wxv': ''
}
}
}
},
}