Gutenberg Tailwind Safelist

I got really tired of safelisting all of my Tailwind classes used in Gutenberg, as well as trying to map all the classes properly in views.

I created a package to handle this for me. (Also my first Sage Package). So far it’s working out well. Although It may be a bit tough to scale on very large sites.

Essentially what this does is it looks at the classes used in your site, either in the “Additional CSS Classes” section in Gutenberg or in the rendered post content, and adds those classes to your Tailwind Safelist. Then it triggers a asset build. It does this on the save_post hook.

Would love the community’s thoughts on it.

Here is the package:

EDIT:
Just added support for ACF Blocks.

8 Likes