Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This rewrite accomplishes a few things:
Fixes group-hover classes are not removed #20. Closes Add test for group-hover classes #22.
Purges selectors that aren't on the same line as their block brace:
Before
Purges empty "at rule" blocks (e.g. empty
@media
blocks).Purges comments, except within property values.
Adds support for nested selector blocks, to prepare for the future. For example, Tailwind has many
.group:hover .group-hover\:X
rules that could be written as.group:hover { .group-hover\:X { ... } }
.Improves performance:
Before
$ bin/test -n test_basic_purge Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s. 1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
After
$ bin/test -n test_basic_purge Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s. 1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
For reference: the purged CSS from the test fixtures was 35,099 bytes before this change, and 22,141 bytes after this change.