leeoniya / dropcss

An exceptionally fast, thorough and tiny unused-CSS cleaner
MIT License
2.13k stars 68 forks source link

Add `tokens` to output #17

Closed irudoy closed 5 years ago

irudoy commented 5 years ago

This PR adds the ability to get raw tokens of cleaned CSS. For example, you can extract all used selectors from it.

leeoniya commented 5 years ago

in general, i was considering returning some form of the tokens (#7) but not in the raw mutable, unfiltered internal format which is optimized for selector testing but not great for consumption. i don't think a flat structure is ideal either.

feel free to open an issue please use #7 to discuss the output format and what should be the option that triggers its generation (i don't want to take the perf hit of generating it unconditionally).

leeoniya commented 5 years ago

@irudoy

you might be interested to know that v1.0.7 now returns {css, sels} where sels is a Set of all retained selectors. also somewhat related is whitelist accumulation: https://github.com/leeoniya/dropcss#accumulating-a-whitelist