Repository navigation
Themes: each one built into a single, versioned file - #320
Merged
Merged
Conversation
A theme is authored as plain CSS that @imports the theme it builds on, and the browser fetched that chain one file at a time (frost, cobalt, coffee, day), unminified and unversioned. The build now inlines each chain as the browser would, every import in place under its media condition, then runs it through Lightning CSS for the bundle's browsers, minified in production (ps: 188 KB in three files becomes 94 KB in one). It fails on an @import left over, a cycle, or a rule it cannot read. Lightning CSS's own bundler is not used: it keeps a file reached twice once, under the first condition only, which dropped day.css's window frame from macos.css by light. The link carries the build in its query (helpers/themeHref.ts, index.html, the pre-boot loader), and the service worker precaches every theme under it, so an update no longer evicts the theme in use and leaves an offline start without one. Scenarios compare the link without the query.
…d fetch no longer ends the install Offline, a theme stylesheet is matched without its ?v=, so a tab left open across a deploy (asking for its own build's version, or none) still gets the new build's copy of that theme. The precache waits for every path to settle, so a theme the network drops cannot let skipWaiting() sweep the last complete cache while the shell is still being written. The docs give the one @import form the build inlines, and pwa.md the new precache.
Offline, a theme stylesheet is looked up by its exact URL first; only a miss falls back to the same theme under any ?v=. The docs say how a theme's @import chain is inlined and what the build accepts.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 1 of the theme-structure review. Each theme used to load as a chain of
@imports fetched one file at a time (frost → cobalt → coffee → day), unminified and unversioned. Now the build makes each one a single file.What changes
vite.config.mtsbundleTheme).@importchain the way the browser would: every import in place, under its media condition, as many times as it is imported.@import, an import cycle, or a rule Lightning CSS can't read.bundle(). It keeps a file that is reached twice only once, under the first condition alone. That dropped day.css's window frame from macos.css in light mode, because macos imports coffee for dark and creama (which imports coffee again) for light.helpers/themeHref.ts,index.html, and the pre-boot loader, which reusesindex.html's query.Verification
pnpm testpasses (lint, typecheck, mocha).@importleft in any built theme;index.htmllinksthemes/coffee.css?v=<token>;--lightningcss-light/darkvariables that Lightning CSS adds.Not done