Repository navigation
feat: add_page(stylesheets=...) for stylesheets only one page loads - #8007
benedikt-bartscher wants to merge 20 commits into
Conversation
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryAdds page-only stylesheets through
Reviews (6) · Last reviewed commit: "Merge commit '24d84bcd1a' into page-styl..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
App(stylesheets=...)loads every stylesheet on every page. A page that needs a stylesheet of its own has no good option today: a global stylesheet costs every route, and React 19's<link rel="stylesheet" precedence>hoisting puts the sheet at the top of<head>, before the app's global stylesheet, so the app's rules beat the page's at equal specificity (and a hoisted sheet is never removed).This PR adds
stylesheets=toadd_pageand@rx.page:Entries are what
App.stylesheetstakes: files or directories inassets/(css, sass, scss) or URLs. They compile into the page's route module as React Router'slinksexport:React Router then
<head>after the app's global stylesheet, in prerendered and exported HTML too, so page rules come after app rules;prefetchStyleLinks), so the page never shows unstyled;Asset files go through the copy/sass step of the app's stylesheets, factored out of
_compile_root_stylesheet(whose output is unchanged), and are imported with?url, so Vite processes and fingerprints them like the global stylesheet.PageContextcarries the page'sstylesheets,page_templatetakes thelinksvar, and the stagedadd_pagea plugin receives inregister_routeacceptsstylesheets=.Follow-up for #6796:
I18nPlugin.expand_routesre-adds each page per locale with explicit arguments, so it has to passstylesheets=page.stylesheetsalong.