Files
punktfunk/web/vite.config.ts
T
enricobuehler 381b059852
ci / rust (push) Has been cancelled
fix(web): add @vitejs/plugin-react — dev mode needs the React Refresh runtime
TanStack Start's dev server requires a React Refresh plugin; without it `/@react-refresh`
404s, the client entry 500s, and nothing hydrates (blank screen — the production build was
unaffected since rollup handles JSX there). Pinned to the v4 line: plugin-react 6 imports
`vite/internal` (Vite 7 only) and we're on Vite 6. Must sit after tanstackStart() in the
plugin list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 17:08:43 +00:00

37 lines
1.4 KiB
TypeScript

import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import viteTsConfigPaths from 'vite-tsconfig-paths'
import tailwindcss from '@tailwindcss/vite'
import { paraglideVitePlugin } from '@inlang/paraglide-js'
// The management API the console drives. In dev we proxy same-origin so the browser
// never needs CORS and the bearer token (when set) rides along untouched. Override the
// target with PUNKTFUNK_MGMT_URL when the host isn't on the default loopback port.
const MGMT_URL = process.env.PUNKTFUNK_MGMT_URL ?? 'http://127.0.0.1:47990'
export default defineConfig({
server: {
proxy: {
'/api': { target: MGMT_URL, changeOrigin: true },
},
},
plugins: [
viteTsConfigPaths({ projects: ['./tsconfig.json'] }),
tailwindcss(),
paraglideVitePlugin({
project: './project.inlang',
outdir: './src/paraglide',
strategy: ['localStorage', 'preferredLanguage', 'baseLocale'],
}),
tanstackStart({
// A management console for a loopback host — render it as a client SPA (no SSR data
// fetching against a token-gated local API), still on the TanStack Start runtime.
spa: { enabled: true },
}),
// Must come AFTER tanstackStart — provides the React JSX transform + Refresh runtime
// that Start's dev mode requires (omitting it leaves the client JS unable to load).
viteReact(),
],
})