Using Tailwind Classes (v3) within Sanity rawHTML Blocks

8 replies
Last updated: Feb 9, 2022
Does anybody have experience with Tailwind classes (v3) that are used within Sanity rawHTML blocks? I need to safelist them to avoid them getting purged in production, but it isn't working.
thanks.
Use this to wrap PortableText with Prose Typography.
And update your tailwind’s purge/content key to scan whether your
serializers
are configured as they likely contain classes.
It's not portable text it's just text.
It's not portable text it's just text.
Our designer would just copy and paste his HTML.
I'm slowly converting things over but in the meantime...
Oh right … I’m not familiar with a “rawHTML” block in Sanity. But yeah if it contains class names it would be difficult to feed those into the Tailwind purge/content setting. You might need to do some sort of export, then regex to find classes, and keep that as a static file alongside your tailwind config.

Typically you’d want to have a migration script to convert HTML to Portable Text to store in Sanity.
Yep, but if you SAW the particular block HTML, you'd see why 🙂 But yes, work in progress. By the way, I figured it out, just need to configure everything properly.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?