diff --git a/src/server/routes/client-entry.tsx b/src/server/routes/client-entry.tsx index 3017886..543494b 100644 --- a/src/server/routes/client-entry.tsx +++ b/src/server/routes/client-entry.tsx @@ -1,9 +1,33 @@ /** @jsxImportSource hono/jsx */ import type { Context } from "hono"; +import { readFileSync } from "fs"; +import { join } from "path"; import type { BlankEnv } from "hono/types"; export function clientEntry(c: Context) { + let jsFile = "/src/client/main.tsx"; + let cssFile = null; + + if (process.env.NODE_ENV === 'production') { + try { + // Read Vite manifest to get the correct file names + const manifestPath = join(process.cwd(), 'dist', '.vite', 'manifest.json'); + const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')); + const entry = manifest['src/client/main.tsx']; + if (entry) { + jsFile = `/assets/${entry.file}`; + if (entry.css) { + cssFile = entry.css.map((css: string) => `/assets/${css}`); + } + } + } catch (error) { + console.warn('Could not read Vite manifest, using fallback:', error); + // Fallback to a generic path + jsFile = "/assets/index-Ccx6A0bN.js"; + } + } + return c.html( @@ -11,12 +35,15 @@ export function clientEntry(c: Context) { Stargirlnails Kiel + {cssFile && cssFile.map((css: string) => ( + + ))} {process.env.NODE_ENV === 'production' ? ( -