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

Fix interaction with other plugins #647

Merged
merged 3 commits into from Apr 12, 2021

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)

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.

None yet

2 participants