go-bananas/web/vite.config.ts

53 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

2026-10-07 15:11:35 +02:00
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: {
2026-10-10 02:30:01 +02:00
'/api': { target: 'http://localhost:8080', changeOrigin: true },
'/rt': { target: 'http://localhost:8080', changeOrigin: true },
'/auth': { target: 'http://localhost:8080', changeOrigin: true },
'/healthz': { target: 'http://localhost:8080', changeOrigin: true },
'/readyz': { target: 'http://localhost:8080', changeOrigin: true },
2026-10-07 15:11:35 +02:00
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/test/setup.ts'],
css: false,
},
})