-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
52 lines (52 loc) · 1.45 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
const {defineConfig} = require('@vue/cli-service')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const {ElementPlusResolver} = require('unplugin-vue-components/resolvers')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
module.exports = defineConfig({
transpileDependencies: true,
productionSourceMap: false,
devServer: {
proxy: {
"/api": {
target: "http://127.0.0.1:9201",
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': ''
},
}
}
},
configureWebpack: config => {
// 开发环境不需要gzip
if (process.env.NODE_ENV !== 'production') return
config.plugins.push(
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: /\.(js|css)$/,// 匹配文件名
threshold: 5120, // 对超过10k的数据压缩
deleteOriginalAssets: false // 不删除源文件
})
)
},
chainWebpack: (config) => {
config
.plugin('AutoImport')
.use(AutoImport({
resolvers: [
ElementPlusResolver({
importStyle: 'css',
exclude: new RegExp(/^(?!.*loading-directive).*$/)
})
],
dts: 'auto-imports.d.ts'
}))
config
.plugin('Components')
.use(Components({
resolvers: [ElementPlusResolver({importStyle: 'css'})],
dts: 'components.d.ts'
}))
}
})