mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
perf(build): the stylesheet minifier had never run
It looked for the tag written as `css` immediately followed by a backtick. The plugin is a Rollup transform, so the module has already been through TypeScript by the time it arrives, and the TS printer puts a space there: `css `. The guard therefore returned null for every stylesheet in the project, and minification never ran once — around 23 KB of explanatory comments went to every user in every release. Matching the tag as a word with optional whitespace turns it on: chunk, raw 1 079 508 -> 1 021 115 B (-58 393) initial view 300 111 -> 287 284 B gzip (-12 816) room to the budget 955 -> 13 782 B The ceiling moves down with the fact, as the tool asks when a graph shrinks past the band. The risk is not the two lines; it is that 23 KB of CSS is minified for the first time. Two witnesses cover it: a browser smoke that puts the original and the minified text into separate stylesheets and compares the serialised rules — 1 049 of them, identical up to the whitespace policy the minifier declares — and a test that takes real comment text out of src/styles and requires it to be absent from dist, so a plugin that silently stops working cannot pass again. Issue: #526 User-Visible: yes
This commit is contained in:
@@ -279,6 +279,26 @@ node scripts/bundle-tree.mjs dist custom_components/houseplan/frontend
|
||||
|
||||
The full HA pytest harness requires Linux/WSL; native Windows lacks `fcntl`.
|
||||
|
||||
## The stylesheet minifier sees TypeScript output, not the source (#526)
|
||||
|
||||
`scripts/css-template-minifier.mjs` runs as a Rollup transform, and by then the
|
||||
module has already been through TypeScript. The TS printer puts a space between
|
||||
a tag and its template, so the source `css`…`` arrives as `css `…``.
|
||||
|
||||
The plugin used to look for the exact string `css` + backtick and therefore
|
||||
returned `null` for every stylesheet in the project: minification never ran
|
||||
once, and roughly 23 KB of explanatory comments were shipped to every user —
|
||||
12.8 KB gzipped in the initial chunk.
|
||||
|
||||
Two consequences for anyone touching this area:
|
||||
|
||||
- match the tag as a word followed by optional whitespace, never as a literal
|
||||
two-character string;
|
||||
- the guard that keeps this honest is not inside the plugin but in
|
||||
`test/bundle-assets.test.mjs`: it takes real comment text out of
|
||||
`src/styles/*.ts` and asserts none of it appears in `dist/**`. A plugin that
|
||||
silently stops working cannot pass it.
|
||||
|
||||
## Do not animate container-relative properties on the plan (#524)
|
||||
|
||||
A CSS property whose value is expressed in container query units — `cqw`,
|
||||
|
||||
Reference in New Issue
Block a user