The idea to leverage dynamicAttributes was borrowed from here. Having data-bs-theme in dynamicAttributes ensures all the relevant @include color-mode(...) rules are preserved.
I've replaced most whitelisted style files with more precise dynamicAttributes or safelist selectors. I've tested quite extensively and hope to have catched all the relevant rules, but I'm not sure. So thorough testing of this PR is very welcome!
From now on we only need to manually add selectors to the PurgeCSS config when they are dynamically modified (i.e. added via JS). All other selectors should automatically get picked up in hugo_stats.json.
Summary
Fixes https://github.com/gethyas/create-hyas/issues/25.
Notes
dynamicAttributes
was borrowed from here. Havingdata-bs-theme
indynamicAttributes
ensures all the relevant@include color-mode(...)
rules are preserved.dynamicAttributes
orsafelist
selectors. I've tested quite extensively and hope to have catched all the relevant rules, but I'm not sure. So thorough testing of this PR is very welcome!hugo_stats.json
.Motivation
Correctness and maintainability.
Checks
npm run test