-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
56 lines (53 loc) · 1.55 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
import { defineConfig,type PluginOption } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from "path";
import { visualizer } from "rollup-plugin-visualizer";
import viteCompression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
vue(),
visualizer({
gzipSize: true,
brotliSize: true,
emitFile: false,
filename: "test.html", //分析图生成的文件名
open: true //如果存在本地服务端口,将在打包后自动展示
}) as PluginOption,
viteCompression({
algorithm : 'brotliCompress',
threshold: 1024,
}),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
base: "./", // 设置打包路径
resolve: {
// ↓路径别名
alias: {
"@": resolve(__dirname, "./src"),
"@pages": resolve(__dirname, "./src/pages"),
"@components": resolve(__dirname, "./src/components"),
"@style": resolve(__dirname, "./src/style"),
}
},
server: {
proxy: {
'/api': { // 匹配请求路径,
target: 'http://localhost:9100/', // 代理的目标地址
changeOrigin: true,
},
'/socket': { // 匹配请求路径,
ws: true,
target: 'ws://localhost:9100/', // 代理的目标地址
changeOrigin: true,
}
}
}
})