You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide an option to add custom CSS attribute selectors like "aria-selected", "data-selected", ...etc. because currently(PurgeCSS version: 3.1.3) there is no option to do that purging effectively other than "value", "checked", "selected", "open" attributes as per the below source code,
As per #277, ability to safelist css attributes were introduced. But that was not enough for our case, because we generate the rules via tailwind(postcss). Similar to whats mentioned here, our css file size grew larger, because we only use some of the classes that gets generated.
Note: The above code is just an example with only three rules, tailwind will generate more similar rules for all of its utilities.
Current Behavior
All the above rules get purged in final css.
Final CSS
// empty
Reason purgecss expects the class to be aria-selected:bg-current[aria-selected] not aria-selected:bg-current, because the attribute selector is not identified in shouldKeepSelector
Expected Behavior
The below rule should not be purged in the final css.
NOTE: Able to obtain the expected behaviour locally by modifying the source code from node modules isPresent = ["value", "checked", "selected", "open", "aria-selected"].includes(selectorNode.attribute)
The text was updated successfully, but these errors were encountered:
navin-moorthy
changed the title
Add an option to add more CSS Attribute Selectors
Provide an option to add more CSS Attribute Selectors
Jan 18, 2021
Feature Request
Provide an option to add custom CSS attribute selectors like
"aria-selected", "data-selected", ...etc.
because currently(PurgeCSS version: 3.1.3) there is no option to do that purging effectively other than"value", "checked", "selected", "open"
attributes as per the below source code,purgecss/packages/purgecss/src/index.ts
Lines 750 to 759 in 07e4e6d
As per #277, ability to safelist css attributes were introduced. But that was not enough for our case, because we generate the rules via tailwind(postcss). Similar to whats mentioned here, our css file size grew larger, because we only use some of the classes that gets generated.
Solution
Example demonstration code
index.html
style.css
Current Behavior
All the above rules get purged in final css.
Final CSS
Expected Behavior
The below rule should not be purged in the final css.
Final CSS
The text was updated successfully, but these errors were encountered: