fix: align official recommendations behavior
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 47s

This commit is contained in:
TerryM
2026-05-19 00:34:29 +08:00
parent 40143afc39
commit e6bc212c4e
5 changed files with 85 additions and 47 deletions

View File

@@ -1,23 +1,28 @@
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
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]",
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]",
},
},
},
},
server: {
port: 5173,
proxy: {
"/api": { target: "http://127.0.0.1:8080", changeOrigin: true },
"/uploads": { target: "http://127.0.0.1:8080", changeOrigin: true },
server: {
port: 5173,
proxy: {
"/api": { target: apiProxyTarget, changeOrigin: true },
"/uploads": { target: apiProxyTarget, changeOrigin: true },
},
},
},
};
});