// 빌드: src/engine.js 를 src/index.template.html 에 인라인해 단일 index.html 생성.
// 최종 클라이언트 요건("단일 HTML 파일, 외부 에셋 0개")을 만족시키기 위한 개발용 도구.
import { readFileSync, writeFileSync } from 'node:fs';
const engine = readFileSync(new URL('./src/engine.js', import.meta.url), 'utf8')
// 모듈 export 키워드 제거 → 같은 스크립트 스코프의 일반 선언으로 인라인
.replace(/^export\s+/gm, '');
const template = readFileSync(new URL('./src/index.template.html', import.meta.url), 'utf8');
if (!template.includes('//__ENGINE__')) {
throw new Error('템플릿에 //__ENGINE__ 자리표시자가 없습니다.');
}
const out = template.replace('//__ENGINE__', engine);
writeFileSync(new URL('./index.html', import.meta.url), out);
console.log(`index.html 생성 완료 (${(out.length/1024).toFixed(1)} KB, 외부 에셋 0개)`);