Tag: babel

RSS Feed

Detecting unused styles in JavaScript with `babel-traverse`

April
8,
2017
·
tooling,
babel,
javascript

Last week, my coworker Charlie asked what it would take to automatically detect and purge unused aphrodite styles in our codebase.

If asked 2 years ago, I probably would have gone with a regex and a string-munging python script, but I’d just spent the past few nights messing with babel plugins, and figured I could probably get pretty far with relatively little work. As it happened, I was impressed by how easy it was using the tools that babel provides.

As a bonus, it also works with React Native because they have the same API, and it could probably be extended to other libraries without too much work.

8 minute read