Files
VibeFinance/frontend/vite.config.js
T

47 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

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,
// In dev: proxy /api naar de API in dezelfde container (zie docker/dev-entrypoint.sh)
proxy: {
"/api": {
target: "http://localhost:3001",
changeOrigin: true,
secure: false,
},
},
},
build: {
outDir: "dist",
sourcemap: false, // zet op true voor staged deploys
chunkSizeWarningLimit: 800,
rollupOptions: {
output: {
// 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)/") },
],
},
},
},
},
define: {
// VITE_API_URL wordt ingebakken tijdens build
__API_URL__: JSON.stringify(process.env.VITE_API_URL ?? "/api"),
__APP_VERSION__: JSON.stringify(process.env.VITE_APP_VERSION ?? pkg.version),
},
});