feat: update global CSS handling in prerender to differentiate between production and development environments, ensuring proper font path management
This commit is contained in:
@@ -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');
|
||||
// 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();
|
||||
|
||||
Reference in New Issue
Block a user