From 0a787f9d2569df14718c4da64031477ac67c2e24 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Sun, 20 Jul 2025 15:47:58 +0200 Subject: [PATCH] feat: update global CSS handling in prerender to differentiate between production and development environments, ensuring proper font path management --- prerender/config.cjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/prerender/config.cjs b/prerender/config.cjs index 877b8f3..314c9e1 100644 --- a/prerender/config.cjs +++ b/prerender/config.cjs @@ -50,10 +50,18 @@ const getWebpackEntrypoints = () => { return entrypoints; }; -// Read global CSS styles and fix font paths for prerender -let globalCss = fs.readFileSync(path.resolve(__dirname, '..', 'src', 'index.css'), 'utf8'); -// Fix relative font paths for prerendered HTML (remove ../public to make them relative to public root) -globalCss = globalCss.replace(/url\('\.\.\/public/g, "url('"); +// Read global CSS styles - use webpack processed CSS in production, raw CSS in development +let globalCss = ''; +if (isProduction) { + // In production, webpack has already processed fonts and inlined CSS + // Don't read raw src/index.css as it has unprocessed font paths + globalCss = ''; // CSS will be handled by webpack's inlined CSS +} else { + // In development, read raw CSS and fix font paths for prerender + globalCss = fs.readFileSync(path.resolve(__dirname, '..', 'src', 'index.css'), 'utf8'); + // Fix relative font paths for prerendered HTML (remove ../public to make them relative to public root) + globalCss = globalCss.replace(/url\('\.\.\/public/g, "url('"); +} // Global CSS collection const globalCssCollection = new Set();