forked from FioraLove/NMSL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue.config.js
More file actions
91 lines (85 loc) · 2.75 KB
/
Copy pathvue.config.js
File metadata and controls
91 lines (85 loc) · 2.75 KB
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
var webpack = require('webpack');
// 是否为生产环境
const isProduction = process.env.NODE_ENV !== 'development';
// gzip压缩
const CompressionWebpackPlugin = require('compression-webpack-plugin')
module.exports = {
/**
* 生产环境打包设置
*/
// publicPath: process.env.NODE_ENV === 'production' ? '/test/' : '/',
// outputDir: 'dist/test',
// assetsDir: 'static',
// productionSourceMap: false, // 关闭map文件
/**
* 开发环境路由设置
*/
publicPath: '/',
devServer: {
// the proxy setting: to solve CORS
proxy: {
'/migus':{
target: 'https://m.music.migu.cn/', // target host
ws: true, // proxy websockets
changeOrigin: true, // needed for virtual hosted sites
pathRewrite: {
'^/migus': '' // rewrite path
},
headers: {
referer: 'https://m.music.migu.cn/',
}
},
'/tophub':{
target: 'https://api.tophub.fun/',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/tophub': ''
}
}
}
},
// gzip压缩
configureWebpack: config => {
// 生产环境相关配置
if (isProduction) {
//gzip压缩
const productionGzipExtensions = ['html', 'js', 'css']
config.plugins.push(
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' + productionGzipExtensions.join('|') + ')$'
),
threshold: 10240, // 只有大小大于该值的资源会被处理 10240
minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
deleteOriginalAssets: false // 删除原文件
})
)
}
},
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
// ============压缩图片 start============
config.module
.rule('images')
.use('image-webpack-loader')
.loader('image-webpack-loader')
.options({ bypassOnDebug: true })
.end()
// ============压缩图片 end============
},
configureWebpack:{
externals: {
'vue': 'Vue',
'element-ui': 'ELEMENT',
'axios': 'axios',
}
}
}