Strip legacy CSS from SX app: no Prism, Ghost, FontAwesome extras
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m10s

Add css_extras parameter to create_base_app. Legacy apps (blog, market
etc) get the default extras (basics.css, cards.css, blog-content.css,
prism.css, FontAwesome). SX app passes css_extras=[] — it uses CSSX
for styling and custom highlighting, not Prism/FA/Ghost.

Reduces <style id="sx-css"> from ~100KB+ of irrelevant CSS to ~5KB
of Tailwind resets + only the utility rules the page actually uses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 16:17:27 +00:00
parent ae1ba46b44
commit 41f4772ba7
2 changed files with 14 additions and 5 deletions

View File

@@ -49,6 +49,7 @@ def create_base_app(
domain_services_fn: Callable[[], None] | None = None, domain_services_fn: Callable[[], None] | None = None,
no_oauth: bool = False, no_oauth: bool = False,
no_db: bool = False, no_db: bool = False,
css_extras: Sequence[str] | None = None,
) -> Quart: ) -> Quart:
""" """
Create a Quart app with shared infrastructure. Create a Quart app with shared infrastructure.
@@ -139,17 +140,24 @@ def create_base_app(
_styles = BASE_DIR / "static" / "styles" _styles = BASE_DIR / "static" / "styles"
_fa_css = BASE_DIR / "static" / "fontawesome" / "css" _fa_css = BASE_DIR / "static" / "fontawesome" / "css"
if (_styles / "tw.css").exists() and not registry_loaded(): if (_styles / "tw.css").exists() and not registry_loaded():
load_css_registry( if css_extras is None:
_styles / "tw.css", # Legacy default: all shared CSS for blog/market/etc apps
extra_css=[ _extra = [
_styles / "basics.css", _styles / "basics.css",
_styles / "cards.css", _styles / "cards.css",
_styles / "blog-content.css", _styles / "blog-content.css",
_styles / "prism.css", _styles / "prism.css",
_fa_css / "all.min.css", _fa_css / "all.min.css",
_fa_css / "v4-shims.min.css", _fa_css / "v4-shims.min.css",
], ]
url_rewrites={"../webfonts/": "/static/fontawesome/webfonts/"}, _rewrites = {"../webfonts/": "/static/fontawesome/webfonts/"}
else:
_extra = [_styles / e if "/" not in e else e for e in css_extras]
_rewrites = {}
load_css_registry(
_styles / "tw.css",
extra_css=_extra,
url_rewrites=_rewrites,
) )
# Dev-mode: auto-reload sx templates when files change on disk # Dev-mode: auto-reload sx templates when files change on disk

View File

@@ -64,6 +64,7 @@ def create_app() -> "Quart":
"sx", "sx",
context_fn=sx_standalone_context if SX_STANDALONE else sx_docs_context, context_fn=sx_standalone_context if SX_STANDALONE else sx_docs_context,
domain_services_fn=register_domain_services, domain_services_fn=register_domain_services,
css_extras=[], # No legacy CSS — SX uses CSSX + custom highlighting
**extra_kw, **extra_kw,
) )