Skip to content

Conversation

@rluba
Copy link
Contributor

@rluba rluba commented Apr 7, 2021

Proposed changes

Currently, PurgeCSS purges at the beginning of tree traversal. If you use other plugins that transform selectors, PurgeCSS purges them before the other plugins had a chance to transform them.

One example where this fails is the following interaction with postcss-nested:

.selector {
    &:hover {
    }
}

PurgeCSS gets rid of &:hover before postcss-nested can transform it to .selector:hover, which would have been kept.

This PR changes the behavior so that PurgeCSS purges after all other transformations have been applied.

Types of changes

What types of changes does your code introduce?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

rluba added 3 commits April 7, 2021 15:13
Otherwise it tries to understand selectors before they have been processed by other plugins.
For example, when using both postcss-nested and purgecss
@Ffloriel
Copy link
Member

Thanks!

@Ffloriel Ffloriel merged commit fb08e3a into FullHuman:master Apr 12, 2021
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.

2 participants