ui: builder: support css

This commit is contained in:
undefined committed 2025-01-16 01:07:37 +08:00
1 parent a63a20cd3d
commit 020b49f661
2 files changed
+12 -6

No files matched your search

+7 -1
View File
@@ -127,7 +127,13 @@ export async function buildUI() {
...entryPoints.map((i) => `import '${relative(tmp, i).replace(/\\/g, '\\\\')}';`),
].join('\n'));
const pages = entry.outputFiles.filter((i) => i.path.endsWith('.js')).map((i) => i.text);
addFile('entry.js', `window._hydroLoad=()=>{ ${pages.join('\n')} };`);
const css = entry.outputFiles.filter((i) => i.path.endsWith('.css')).map((i) => i.text);
addFile('entry.js', `window._hydroLoad=()=>{
const style = document.createElement('style');
style.textContent = ${JSON.stringify(css.join('\n'))};
document.head.appendChild(style);
${pages.join('\n')}
};`);
UiContextBase.constantVersion = hashes['entry.js'];
for (const key in vfs) {
if (newFiles.includes(key)) continue;