-
Notifications
You must be signed in to change notification settings - Fork 23
/
vite.config.mts
67 lines (63 loc) · 1.6 KB
/
vite.config.mts
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
import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv, type UserConfigFnObject, UserConfig } 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";
const env = loadEnv("", process.cwd());
// https://vitejs.dev/config/
const config: UserConfigFnObject = ({ command, mode }): UserConfig => {
let c: UserConfig = {
server: {
host: true,
proxy: {
"/api": {
target: env.VITE_SERVER_TARGET || "http://127.0.0.1:8088",
changeOrigin: true,
ws: true
},
"/oauth2": {
target: env.VITE_SERVER_TARGET || "http://127.0.0.1:8088",
changeOrigin: true,
ws: false
}
}
},
plugins: [
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
}),
vue()
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
build: {
cssCodeSplit: true,
minify: "esbuild",
cssMinify: "lightningcss",
reportCompressedSize: false,
assetsInlineLimit: 0 // 禁止内敛为base64
},
base: env.VITE_BASEURL,
css: {
lightningcss: {}
},
json: {
stringify: true
},
envPrefix: "VITE_"
};
if (mode !== "development") {
c.esbuild = {
drop: ["console", "debugger"]
};
}
return c;
};
export default defineConfig(config);