Mat now we will have interactivity?
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful

This commit is contained in:
2026-02-06 20:36:38 -03:00
parent d2995e4a08
commit a52938f6cf
2 changed files with 10 additions and 3 deletions

View File

@@ -34,7 +34,9 @@ try {
dimensions: [{ width: 1280, height: 720 }], dimensions: [{ width: 1280, height: 720 }],
penthouse: { timeout: 30000 }, penthouse: { timeout: 30000 },
}); });
writeFileSync(htmlPath, outHtml, 'utf-8'); // Ensure _app asset paths stay absolute (critical may rewrite; host-based routing needs /_app/...)
const normalized = outHtml.replace(/\.\/_app\//g, '/_app/');
writeFileSync(htmlPath, normalized, 'utf-8');
console.log(`Critical CSS inlined in ${htmlPath}`); console.log(`Critical CSS inlined in ${htmlPath}`);
} catch (err) { } catch (err) {
const msg = err instanceof Error ? err.message : String(err); const msg = err instanceof Error ? err.message : String(err);

View File

@@ -73,15 +73,20 @@ try {
console.log('No SvelteKit inline bootstrap script found in', htmlPath); console.log('No SvelteKit inline bootstrap script found in', htmlPath);
process.exit(0); process.exit(0);
} }
const content = found.content; let content = found.content;
// Bootstrap runs from /_app/immutable/bootstrap.xxx.js; imports like "./_app/immutable/entry/..."
// would resolve to /_app/immutable/_app/immutable/entry/... (duplicate). Use directory-relative paths.
content = content.replace(/\.\/_app\/immutable\//g, './');
const hash = createHash('sha256').update(content).digest('hex').slice(0, 8); const hash = createHash('sha256').update(content).digest('hex').slice(0, 8);
const filename = `bootstrap.${hash}.js`; const filename = `bootstrap.${hash}.js`;
const immutableDir = join(buildDir, '_app', 'immutable'); const immutableDir = join(buildDir, '_app', 'immutable');
mkdirSync(immutableDir, { recursive: true }); mkdirSync(immutableDir, { recursive: true });
const scriptPath = join(immutableDir, filename); const scriptPath = join(immutableDir, filename);
writeFileSync(scriptPath, content.trimStart(), 'utf-8'); writeFileSync(scriptPath, content.trimStart(), 'utf-8');
const scriptTag = `<script src="./_app/immutable/${filename}"></script>`; const scriptTag = `<script src="/_app/immutable/${filename}"></script>`;
html = html.slice(0, found.start) + scriptTag + html.slice(found.end); html = html.slice(0, found.start) + scriptTag + html.slice(found.end);
// Use absolute paths for _app assets so they resolve correctly (host-based routing, redirects)
html = html.replace(/\.\/_app\//g, '/_app/');
writeFileSync(htmlPath, html, 'utf-8'); writeFileSync(htmlPath, html, 'utf-8');
console.log('Externalized SvelteKit bootstrap to', scriptPath); console.log('Externalized SvelteKit bootstrap to', scriptPath);
} catch (err) { } catch (err) {