// 由规范页面 src/genesis/server/static/chat.html 生成本地开发用 frontend/index.html // (仅用于 Vite dev;写入 index.html 供 Vite 作为入口,产物不入库) import { readFileSync, writeFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; const here = dirname(fileURLToPath(import.meta.url)); const frontend = resolve(here, '..'); const canonical = resolve(frontend, '../src/genesis/server/static/chat.html'); let html = readFileSync(canonical, 'utf8'); html = html // 入口脚本 -> 指向 TS 源(Vite HMR) .replace(/') // 移除生产 CSS 链接(dev 由 main.ts 导入 chat.css,启用样式 HMR) .replace(/\s*/, '') // 去掉资源版本占位 .replace(/\?v=__ASSET_VER__/g, ''); writeFileSync(resolve(frontend, 'index.html'), html); console.log('generated frontend/index.html from src/genesis/server/static/chat.html');