Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PurgeCSS config #27

Merged
merged 2 commits into from
Oct 10, 2023
Merged

Improve PurgeCSS config #27

merged 2 commits into from
Oct 10, 2023

Conversation

salim-b
Copy link
Contributor

@salim-b salim-b commented Oct 8, 2023

Summary

Fixes #25.

Notes

  • 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.

Motivation

Correctness and maintainability.

Checks

  • Read Create a Pull Request
  • Supports all screen sizes (if relevant)
  • Supports both light and dark mode (if relevant)
  • Passes npm run test

Copy link
Member

@h-enk h-enk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W.O.W. I really like this one 😄

@h-enk h-enk merged commit f08c66b into thuliteio:main Oct 10, 2023
@salim-b salim-b deleted the better-purgecss branch October 10, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate hugo_stats.json for PurgeCSS
2 participants