added ability to exclude current rule with an ignore comment placed in… #210
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.
Proposed changes
Added a feature to ignore current class with a comment
/* purgecss ignore current */
inside of it.Types of changes
Checklist
PR to docs: FullHuman/purgecss-docs#33
Further comments
At my current project we use postcss together with scss and the problem arises when we need to ignore lists of generated classes that will be used dynamically. There's to much to keep them in the whitelist or regexp patterns array and it gets problematic to maintain it, and existing ignore comments do not really cover our case easily.
If we use
/* purgecss ignore */
before generated class then it doesn't work since the comment is left in the body of parent class:turns to
And we can't really use ignore
start
andend
comments because scss files have all classes nested under one parent so the whole file will be ignored. We want to ignore only lists that are used dynamically and there is no code reference to them.Adding comment for ignoring current class easily fixes the issue and doesn't require any list maintaining. If style files are gone no dead code is left behind.