3 ms·
> Have used tools like this before, and invariably end up accidentally stripping styles from an <insert JS UI lib> component with a dynamically assigned classNa
by andybak 10y ago
> Have used tools like this before, and invariably end up accidentally stripping styles from an <insert JS UI lib> component with a dynamically assigned className or something equally silly.
The only way I can think to handle this is if you've got a really thorough test suite in Selenium or similar. Do a before and after, capture screengrabs of everything and flag up where the 'new' CSS has caused visual differences.
It's a horrible solution but then it's a horrible problem.
- eriknstr 10y agoAlternatively, you could dump the DOM of each rendered test case and use that to construct a single document that has all the classes and ids that are in use in it and run UnCSS on that. Maybe. Not saying it will be easy (in particular rules which are about certain hierarchies might get hairy) but I think it's worth a shot.
- ry_ry 10y agoHuh, pulling it out the unit tests is a pretty good idea actually - if the test coverage is good enough it might be worth a bit of investigation. Especially since it'd be an optional build step you'd only want to run infrequently.