2026-04-20 09:20:50 +00:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
|
|
const rawPort = process.env.PORT;
|
|
|
|
|
|
|
|
|
|
if (!rawPort) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
"PORT environment variable is required but was not provided.",
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const port = Number(rawPort);
|
|
|
|
|
|
|
|
|
|
if (Number.isNaN(port) || port <= 0) {
|
|
|
|
|
throw new Error(`Invalid PORT value: "${rawPort}"`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const basePath = process.env.BASE_PATH;
|
|
|
|
|
|
|
|
|
|
if (!basePath) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
"BASE_PATH environment variable is required but was not provided.",
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-13 14:08:11 +00:00
|
|
|
const apiTarget = process.env.VITE_API_PROXY_TARGET ?? "http://localhost:8080";
|
|
|
|
|
|
2026-04-20 09:20:50 +00:00
|
|
|
export default defineConfig({
|
|
|
|
|
base: basePath,
|
2026-05-13 14:08:11 +00:00
|
|
|
plugins: [react(), tailwindcss()],
|
2026-04-20 09:20:50 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(import.meta.dirname, "src"),
|
|
|
|
|
},
|
|
|
|
|
dedupe: ["react", "react-dom"],
|
|
|
|
|
},
|
|
|
|
|
root: path.resolve(import.meta.dirname),
|
|
|
|
|
build: {
|
|
|
|
|
outDir: path.resolve(import.meta.dirname, "dist/public"),
|
|
|
|
|
emptyOutDir: true,
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port,
|
|
|
|
|
host: "0.0.0.0",
|
|
|
|
|
allowedHosts: true,
|
|
|
|
|
fs: {
|
|
|
|
|
strict: true,
|
|
|
|
|
deny: ["**/.*"],
|
|
|
|
|
},
|
|
|
|
|
proxy: {
|
|
|
|
|
"/api": {
|
2026-05-13 14:08:11 +00:00
|
|
|
target: apiTarget,
|
2026-04-20 09:20:50 +00:00
|
|
|
changeOrigin: false,
|
|
|
|
|
ws: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
preview: {
|
|
|
|
|
port,
|
|
|
|
|
host: "0.0.0.0",
|
|
|
|
|
allowedHosts: true,
|
|
|
|
|
},
|
|
|
|
|
});
|