mrnocreativity / postcss-critical-split

A PostCSS plugin that takes existing CSS files and splits out the annotated critical styles into a seperate file.
MIT License
89 stars 6 forks source link

Is there a way to pass a whitelist of class selectors in config instead of annotating in css? #19

Open afzalsayed96 opened 4 years ago

mrnocreativity commented 4 years ago

Sounds like a nice feature but no, this does not yet exist. Giving it some thought, I can easily see this become REALLY complicated and bug prone (since we'll have to interpret the selectors in the list according to the CSS spec and match them against the traversal list int he css files itself.

Since some selectors might include selectors that are in the file but not with exact matches.

Example whitelist: body > p > span.label css file: p > span.label

This could easily become a very complicated feature with many potential bugs.

afzalsayed96 commented 4 years ago

That's a valid example. I don't know how we can handle that. Maybe instead of selectors, user can provide a selector pattern.

This feature would be very helpful for those who are using a css library and want to mark some of the styles as critical inside the lib.