2026-05-19 00:34:29 +08:00
|
|
|
import { defineConfig, loadEnv } from "vite";
|
2026-05-16 00:18:22 +08:00
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
|
2026-05-19 00:34:29 +08:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
|
const apiProxyTarget = env.DEV_API_PROXY_TARGET || "http://127.0.0.1:8080";
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
// Entry script at site root (/index-[hash].js); lazy chunks + CSS stay under /assets/.
|
|
|
|
|
entryFileNames: "[name]-[hash].js",
|
|
|
|
|
chunkFileNames: "assets/[name]-[hash].js",
|
|
|
|
|
assetFileNames: "assets/[name]-[hash][extname]",
|
|
|
|
|
},
|
2026-05-16 00:18:22 +08:00
|
|
|
},
|
|
|
|
|
},
|
2026-05-19 00:34:29 +08:00
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
proxy: {
|
2026-05-23 17:56:38 +08:00
|
|
|
"/apnew/api": {
|
|
|
|
|
target: apiProxyTarget,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/apnew/, ""),
|
|
|
|
|
},
|
2026-05-19 00:34:29 +08:00
|
|
|
"/api": { target: apiProxyTarget, changeOrigin: true },
|
|
|
|
|
"/uploads": { target: apiProxyTarget, changeOrigin: true },
|
|
|
|
|
},
|
2026-05-16 00:18:22 +08:00
|
|
|
},
|
2026-05-19 00:34:29 +08:00
|
|
|
};
|
2026-05-16 00:18:22 +08:00
|
|
|
});
|