Files
2026-09-08 10:50:13 +05:30

81 lines
1.5 KiB
TypeScript

import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const apiUrl = env.VITE_API_BASE_URL || "http://localhost:20001/api";
const apiTarget = apiUrl.replace(/\/api\/?$/, "");
const wsTarget = apiTarget.replace(/^http/, "ws");
return {
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
optimizeDeps: {
exclude: ["lucide-react"],
},
server: {
port: 5174,
allowedHosts: true,
proxy: {
/*
--------------------------------
YOUR APPLICATION BACKEND
--------------------------------
*/
"/api/saas": {
target: env.VITE_SAAS_API_URL || "http://localhost:8000",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/saas/, "/api"),
},
"/api": {
target: apiTarget,
changeOrigin: true,
},
"/socket.io": {
target: apiTarget,
ws: true,
changeOrigin: true,
},
"/socket": {
target: wsTarget,
ws: true,
changeOrigin: true,
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
"vendor-react": ["react", "react-dom", "react-router-dom"],
},
},
},
chunkSizeWarningLimit: 900,
},
};
});