-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
143 lines (131 loc) · 3.37 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
const pxtorem = require('postcss-pxtorem')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const path = require('path')
const { ANALYZER, CONSOLE } = process.env
const VConsolePlugin = require('vconsole-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = {
configureWebpack: {
optimization: {
splitChunks: {
cacheGroups: {
/*
最少引用两次的第三方库才抽离为公共文件
*/
vendors: {
name: 'chunk-vendors',
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial',
minChunks: 2,
},
common: {
name: 'chunk-common',
minChunks: 2,
priority: -20,
chunks: 'initial',
reuseExistingChunk: true,
},
},
},
},
plugins: [
new CopyPlugin({
patterns: [
{
from: './*.txt',
},
],
}),
],
},
pages: {
index: {
entry: 'src/modules/alipay/main.js',
template: 'public/index.html',
title: '订单详情',
},
qyk: {
entry: 'src/modules/qyk/main.js',
template: 'public/index.html',
title: '权益卡',
},
// recharge: {
// entry: 'src/modules/recharge/main.js',
// template: 'src/modules/recharge/public/index.html',
// title: '充值',
// },
recharge: {
entry: 'src/modules/recharge/main.js',
template: 'src/modules/recharge/public/index.html',
title: '充值',
},
refresh: {
entry: 'src/modules/recharge/refresh.js',
template: 'src/modules/recharge/public/index.html',
title: '等待支付结果',
},
result: {
entry: 'src/modules/recharge/result.js',
template: 'src/modules/recharge/public/index.html',
title: '充值结果',
},
},
css: {
loaderOptions: {
postcss: {
plugins: [
pxtorem({
rootValue: 75, // 换算的基数(设计图750的根字体为75)
propList: ['*'],
exclude: /node_modules/i, // 禁止转换安装包下的任何组件
}),
],
},
},
},
chainWebpack(config) {
/*
别名配置
*/
config.resolve.alias.set('@', '/src')
/*
打包分析
*/
ANALYZER && config.plugin('analyzer').use(BundleAnalyzerPlugin)
CONSOLE && config.plugin('console').use(VConsolePlugin, [{ enable: true }])
// config.plugin('copy-webpack-plugin').use(CopyPlugin, [{
// patterns: [
// {
// from: 'src/config/*.txt',
// to: 'dist',
// context: 'mpa/',
// },
// ],
// }])
/*
图片小于10k就自动转base64
*/
config.module
.rule('images')
.use('url-loader')
.loader('url-loader')
.tap((options) => Object.assign(options, { limit: 10240 }))
/*
优化moment库打包体积
*/
// config.plugin('moment').use(IgnorePlugin, [/^\.\/locale$/, /moment$/])
},
devServer: {
// 'http://local.sldshop.com',
// proxy: {
// '/': {
// target: 'http://mall-bsy.vxwei.com/',
// changeOrigin: true,
// pathRewrite: { '^/': '' },
// },
// },
contentBase: path.resolve(__dirname, 'dist'),
proxy: 'http://mall-bsy.vxwei.com/',
},
};