Skip to content

Commit d82b3c1

Browse files
committed
Refactor PostCSS config: trim content globs and variable safelist
Content globs: remove **/*.js (redundant with TS source) and **/*.html (matched nothing), remove **/*.scss (defines CSS rather than consuming it), add **/*.ts as the reliable selector source alongside **/*.templ. Variable safelist: PurgeCSS tracks variable usage exclusively within the CSS it processes, not via content file scanning. The six variables that were over-specified survive automatically because they appear in var() expressions inside kept rules in _overrides.scss and country-map.scss. Only --bs-primary needs explicit safelisting as it is solely consumed via getPropertyValue() in country-map.ts and never referenced in any CSS var() expression.
1 parent 5cddc65 commit d82b3c1

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

postcss.config.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import cssnano from "cssnano";
44
module.exports = {
55
plugins: [
66
purgeCSSPlugin({
7-
content: ["**/*.js", "**/*.html", "**/*.templ"],
7+
content: ["**/*.templ", "**/*.ts"],
88
skippedContentGlobs: ["node_modules/**", "tests/**", "tmp/**"],
99
variables: true,
1010
safelist: {
1111
greedy: [/^svgMap-/],
12-
variables: [
13-
"--bs-primary",
14-
"--bs-body-color",
15-
"--bs-body-bg",
16-
"--bs-secondary-bg",
17-
"--bs-secondary-color",
18-
"--bs-border-color",
19-
"--bs-link-hover-color",
20-
],
12+
// --bs-primary is only consumed via getPropertyValue() in country-map.ts
13+
// and never referenced in a CSS var() expression, so PurgeCSS cannot
14+
// detect it automatically and it must be safelisted explicitly.
15+
variables: ["--bs-primary"],
2116
},
2217
}),
2318
cssnano({ preset: ["cssnano-preset-advanced"] }),

0 commit comments

Comments
 (0)