- 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
25 lines
793 B
TypeScript
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,
|
|
},
|
|
})
|