-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
78 lines (74 loc) · 2.12 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 vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import { defineConfig, loadEnv, ConfigEnv } from "vite";
import viteCompression from "vite-plugin-compression";
const pathResolve = (dir: string) => {
return resolve(__dirname, ".", dir);
};
const alias: Record<string, string> = {
"/@": pathResolve("./src/"),
};
const viteConfig = defineConfig((mode: ConfigEnv) => {
const env = loadEnv(mode.mode, process.cwd());
return {
plugins: [
vue(),
viteCompression(),
],
root: process.cwd(),
resolve: { alias },
base: mode.command === "serve" ? "./" : env.VITE_PUBLIC_PATH,
optimizeDeps: { exclude: ["vue-demi"] },
server: {
host: "127.0.0.1",
port: env.VITE_PORT as unknown as number,
open: JSON.parse(env.VITE_OPEN),
hmr: true,
proxy: {
"/api": {
target: "http://127.0.0.1:8230", //本地
ws: true,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, "/api"),
},
},
},
build: {
outDir: "dist",
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
manualChunks(id) {
if (id.includes("node_modules")) {
return (
id
.toString()
.match(/\/node_modules\/(?!.pnpm)(?<moduleName>[^\/]*)\//)
?.groups!.moduleName ?? "vender"
);
}
},
},
},
},
css: {
preprocessorOptions: {
css: { charset: false },
scss: {
api: "modern-compiler", // or 'modern'
},
},
},
define: {
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
__NEXT_VERSION__: JSON.stringify(process.env.npm_package_version),
__NEXT_NAME__: JSON.stringify(process.env.npm_package_name),
"process.env": env,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
},
};
});
export default viteConfig;