parsimony/admin/vite.config.ts
tgiachi 5a0dd7f6d6 feat(adminui): embed the admin SPA and serve it next to the API
- Add internal/adminui with a SPA handler: index fallback for client routes, immutable caching for hashed assets, 404 for missing assets, security headers
- Answer 503 with a hint when the UI has not been built, so go build always works
- Mount the UI at / and the API at /api/ on the same listener, no CORS needed
- Scaffold admin/ with Vite, React, TypeScript, Tailwind v4, shadcn/ui and Vitest
2026-11-09 15:29:12 +01:00

25 lines
793 B
TypeScript

/// <reference types="vitest/config" />
import path from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
// The Go binary embeds the build output from internal/adminui/dist.
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: { alias: { '@': path.resolve(import.meta.dirname, 'src') } },
build: {
outDir: '../internal/adminui/dist',
emptyOutDir: false, // keeps .gitkeep; the build script removes stale files
},
server: {
// `npm run dev` talks to a daemon running on the default API port.
proxy: { '/api': 'http://127.0.0.1:8080' },
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/test/setup.ts'],
css: false,
},
})