- 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
8 lines
368 B
JavaScript
8 lines
368 B
JavaScript
// Empties the Go embed directory but keeps .gitkeep, so `go build` always works.
|
|
import { readdirSync, rmSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
const dist = new URL('../../internal/adminui/dist', import.meta.url).pathname
|
|
for (const name of readdirSync(dist)) {
|
|
if (name !== '.gitkeep') rmSync(join(dist, name), { recursive: true, force: true })
|
|
}
|