Gets rid of classes in your CSS.
It removes all selectors that contain the class and removes the rule altogether if it doesn’t have any selectors left.
This does not seem very smart, but it’s by design. For instance, what would you expect after processing div > .remove > .keep
? Should it rather be div > * > .keep
or should the rule be discarded? symdiff-css-autoremove
does not try to guess.
The module exports a function that takes the following arguments:
- The css string
- An array of the classes to remove
- (optional) An object containing some options
- replaceSelectorFn: A function that takes the selector (string) and the classes to remove as argument and should return a string. Here you can implement custom logic if the default behavior doesn’t work for you. If you want the selector to be discarded, return the empty string.
Also all options that css.stringify
takes.
removeCss(input, ['remove-me']);
Transforms this:
.remove-me {
border: 1px solid;
color: red:
}
.keep-me,
div > .remove-me {
color: blue;
}
...to this:
.keep-me {
color: blue;
}