-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
78 lines (76 loc) · 1.92 KB
/
vite.config.ts
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
import { fileURLToPath, URL } from 'node:url'
import compression from 'vite-plugin-compression'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// install unplugin-vue-components unplugin-auto-import for element-plus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3000,
host: '0.0.0.0',
cors: true,
proxy: {
'/api': {
target: 'http://82.157.111.212:8001',
changeOrigin: true,
},
'/8077': {
target: 'http://82.157.111.212',
changeOrigin: true,
}
}
},
plugins: [
vue(),
vueJsx(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
compression({
algorithm: 'gzip',
ext: '.gz'
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
}
},
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
},
/** 消除打包大小超过 500kb 警告 */
chunkSizeWarningLimit: 1500,
/** Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 */
minify: "terser",
/** 在打包代码时移除 console.log、debugger 和 注释 */
terserOptions: {
compress: {
drop_console: false,
drop_debugger: true,
pure_funcs: ["console.log"]
},
format: {
/** 删除注释 */
comments: false
}
},
/** 打包后静态资源目录 */
assetsDir: "static"
},
})