Skip to content

Commit 760dcbb

Browse files
committed
docs: clarify PurgeCSS silent-removal failure mode in ADR 0005
Flag the custom defaultExtractor and the safelist as load-bearing guardrails, not incidental config: the stock extractor shreds : / variants, and any class not present as a literal token is dropped with no build error.
1 parent 9e0d9c4 commit 760dcbb

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

docs/adr/0005-seo-metadata-and-purged-self-hosted-assets.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,24 @@ the whole site to a throwaway dir, and purge the source against that output
2121
(`purgecss.config.cjs`). Hugo then `minify | fingerprint`s the committed file at
2222
build time so the immutable `Cache-Control` in `netlify.toml` is safe.
2323

24-
**Purging against built HTML misses classes that aren't in the committed output.**
25-
The extractor keeps Tailwind tokens (`:` `/` `.` survive), and runtime-toggled
26-
classes (Alpine `:class`, JS `classList`) are caught because they appear as
27-
literals in the HTML. The gap is classes injected from data that only exists at
28-
deploy time — the activity-dot colors written into `data/community_stats.json` by
29-
`.github/scripts/fetch-discourse-activity.js` (and the `deploy.yml` fallback).
30-
Those are pinned in the `purgecss.config.cjs` safelist.
24+
**Purging silently drops any class it cannot find as a literal token** — no build
25+
error, just elements that render unstyled in production. The config
26+
(`purgecss.config.cjs`) is the only thing between "smaller CSS" and "broken
27+
styles," and two parts of it are load-bearing and must not be weakened:
28+
29+
- The **custom `defaultExtractor`**. PurgeCSS's stock extractor splits candidate
30+
tokens on `:` and `/`, which would shred every Tailwind variant
31+
(`lg:grid-cols-3`, `hover:bg-blue-300`, `w-1/2`). The regex keeps those
32+
characters; drop or "simplify" it and the site loses its responsive/state
33+
utilities sitewide, silently.
34+
- The **safelist**. Runtime-toggled classes (Alpine `:class`, JS `classList`
35+
`hidden`, `transform rotate-180`, the YouTube-facade `absolute inset-0 …`)
36+
survive because they appear as literals in the built HTML, but are pinned
37+
anyway against markup churn. The genuine gap is classes injected from data that
38+
only exists at deploy time — the activity-dot colors written into
39+
`data/community_stats.json` by `.github/scripts/fetch-discourse-activity.js`
40+
(and the `deploy.yml` fallback), which never appear in the committed build and
41+
are pinned explicitly.
3142

3243
## Considered options
3344

0 commit comments

Comments
 (0)