2026-09-04 09:19:14 +02:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import { readFileSync } from "fs";
|
|
|
|
|
import { fileURLToPath } from "url";
|
|
|
|
|
import { dirname, join } from "path";
|
|
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
const pkg = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf-8"));
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
2026-09-04 11:51:29 +02:00
|
|
|
// In dev: proxy /api naar de API in dezelfde container (zie docker/dev-entrypoint.sh)
|
2026-09-04 09:19:14 +02:00
|
|
|
proxy: {
|
|
|
|
|
"/api": {
|
2026-09-04 11:51:29 +02:00
|
|
|
target: "http://localhost:3001",
|
2026-09-04 09:19:14 +02:00
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
outDir: "dist",
|
|
|
|
|
sourcemap: false, // zet op true voor staged deploys
|
|
|
|
|
chunkSizeWarningLimit: 800,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
2026-09-04 12:21:06 +02:00
|
|
|
// Splits vendor chunks voor betere caching. Vite 8 bundelt met
|
|
|
|
|
// Rolldown; die kent de object-vorm van manualChunks niet, dus dit
|
|
|
|
|
// gaat via advancedChunks.
|
|
|
|
|
advancedChunks: {
|
|
|
|
|
groups: [
|
|
|
|
|
// RegExp via constructor: module-ids zijn genormaliseerd met "/"
|
|
|
|
|
{ name: "react", test: new RegExp("node_modules/(react|react-dom|scheduler)/") },
|
|
|
|
|
],
|
2026-09-04 09:19:14 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
define: {
|
|
|
|
|
// VITE_API_URL wordt ingebakken tijdens build
|
|
|
|
|
__API_URL__: JSON.stringify(process.env.VITE_API_URL ?? "/api"),
|
2026-09-10 14:03:34 +02:00
|
|
|
__APP_VERSION__: JSON.stringify(process.env.VITE_APP_VERSION || pkg.version),
|
2026-09-04 09:19:14 +02:00
|
|
|
},
|
|
|
|
|
});
|