import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' declare const process: { env: Record } const API_TARGET = process.env.API_URL || 'http://localhost:8787' // Vite config — React + TS. Honors the PORT env (used by the preview harness); // falls back to 5173 and auto-increments if busy. export default defineConfig({ plugins: [react()], // Keep logical paths under the project root even when served via a symlink/junction // (needed so the TS/JSX transform applies in the preview harness). resolve: { preserveSymlinks: true }, server: { port: process.env.PORT ? Number(process.env.PORT) : 5173, // The CMS API and its uploaded media are served by server/index.mjs in dev too, // so publishing from /admin behaves exactly as it does in production. proxy: { '/api': { target: API_TARGET, changeOrigin: true }, '/content/uploads': { target: API_TARGET, changeOrigin: true }, '/content/site-content.json': { target: API_TARGET, changeOrigin: true }, '/sitemap.xml': { target: API_TARGET, changeOrigin: true }, }, }, })