1
0

Added --dev flag to ./serve-locally.sh

This commit is contained in:
2026-03-22 10:35:43 +01:00
parent 993443be9e
commit 17fcbf4d93
4 changed files with 166 additions and 118 deletions

View File

@@ -17,18 +17,19 @@ if (analyticsEnabled) {
` <script defer src="${UMAMI_SCRIPT_URL}" data-website-id="${UMAMI_WEBSITE_ID}"></script>\n`;
}
// Cache the processed index.html at startup
// Cache the processed index.html (disabled when NO_CACHE is set, e.g. during --dev)
const noCache = !!process.env.NO_CACHE;
let cachedIndexHtml = null;
function getIndexHtml() {
if (cachedIndexHtml) return cachedIndexHtml;
if (!noCache && cachedIndexHtml) return cachedIndexHtml;
const indexPath = join(DIST, 'index.html');
if (!existsSync(indexPath)) return null;
let html = readFileSync(indexPath, 'utf-8');
if (analyticsSnippet) {
html = html.replace('</head>', analyticsSnippet + '</head>');
}
cachedIndexHtml = html;
return cachedIndexHtml;
if (!noCache) cachedIndexHtml = html;
return html;
}
const MIME = {