import tailwindcss from '@tailwindcss/vite' import react from '@vitejs/plugin-react' import { defineConfig } from 'vite' /** * The admin UI is served by the Go binary from web/dist, and in development by * Vite with a proxy to the API. The proxy matters because the admin UI must be * same-origin in production: the session cookie is HttpOnly and SameSite=Lax, so * a cross-origin development setup would not authenticate at all and the problem * would look like a bug rather than a topology difference. */ export default defineConfig({ plugins: [react(), tailwindcss()], build: { outDir: 'dist', emptyOutDir: true, target: 'es2022', sourcemap: true, // Split the vendor code out so that an application-only deploy does not // invalidate the framework chunk in every user's cache. Rolldown takes a // function rather than the object form esbuild used. rollupOptions: { output: { manualChunks(id: string) { if (!id.includes('node_modules')) return undefined if (/[\\/](react|react-dom|react-router|react-router-dom)[\\/]/.test(id)) { return 'react' } if (id.includes('@tanstack')) return 'query' return undefined }, }, }, }, server: { port: 5173, strictPort: true, proxy: { '/api': { target: 'http://localhost:8081', changeOrigin: true }, '/rt': { target: 'http://localhost:8081', changeOrigin: true }, '/auth': { target: 'http://localhost:8081', changeOrigin: true }, '/healthz': { target: 'http://localhost:8081', changeOrigin: true }, '/readyz': { target: 'http://localhost:8081', changeOrigin: true }, }, }, test: { environment: 'jsdom', globals: true, setupFiles: ['./src/test/setup.ts'], css: false, }, })