2026-04-02 15:49:40 +08:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
|
import { resolve } from "path";
|
2026-03-27 22:20:25 +08:00
|
|
|
|
|
|
|
|
// 根据环境设置 base 路径
|
|
|
|
|
const getBase = (mode: string) => {
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case "test":
|
2026-04-02 15:49:40 +08:00
|
|
|
return "/web-test/";
|
2026-03-27 22:20:25 +08:00
|
|
|
case "production":
|
2026-04-02 15:49:40 +08:00
|
|
|
return "/web/";
|
2026-03-27 22:20:25 +08:00
|
|
|
default:
|
2026-04-02 15:49:40 +08:00
|
|
|
return "/";
|
2026-03-27 22:20:25 +08:00
|
|
|
}
|
2026-04-02 15:49:40 +08:00
|
|
|
};
|
2026-03-27 22:20:25 +08:00
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
return {
|
|
|
|
|
base: getBase(mode),
|
|
|
|
|
plugins: [vue()],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": resolve(__dirname, "src"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
2026-04-02 15:49:40 +08:00
|
|
|
host: "0.0.0.0",
|
2026-03-27 22:20:25 +08:00
|
|
|
port: 3000,
|
|
|
|
|
proxy: {
|
|
|
|
|
"/api": {
|
2026-04-02 15:49:40 +08:00
|
|
|
target: "http://localhost:8580",
|
2026-03-27 22:20:25 +08:00
|
|
|
changeOrigin: true,
|
|
|
|
|
// rewrite: (path) => path.replace(/^\/api/, ''),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-02 15:49:40 +08:00
|
|
|
};
|
|
|
|
|
});
|