-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
63 lines (60 loc) · 1.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
const path = require('path')
const fs = require('fs')
const resolve = dir => {
return path.join(__dirname, dir)
}
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const BASE_URL = './'
module.exports = {
publicPath: BASE_URL,
lintOnSave: false,
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('@c', resolve('src/components'))
.set('@s', resolve('src/static'))
.set('@p', resolve('src/pages'))
},
productionSourceMap: false,
configureWebpack: (config)=>{
if(process.env.NODE_ENV === 'production'){
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true // 去除console
config.plugins.push( // 压缩gzip
new CompressionWebpackPlugin({
filename: '[path].gz[query]', // 提示示[email protected]的话asset改为filename
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
)
}
},
css: {
loaderOptions: {
sass: {
prependData: `
@import "~@/assets/scss/index.scss";
`
}
}
},
devServer: {
open: false, //是否自动弹出浏览器页面
host: "localhost",
port: '8080',
https: false,
hotOnly: false,
proxy: {
'/api': {
target: 'https://whallet.net', //API服务器的地址
ws: true, //代理websockets
changeOrigin: true, // 虚拟的站点需要更管origin
pathRewrite: { //重写路径 比如'/api/aaa/ccc'重写为'/aaa/ccc'
'^/api': ''
}
}
},
}
}