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.
Feb 8, 2022, 8:30 PM
thanks.
Feb 8, 2022, 9:39 PM
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.
Feb 8, 2022, 9:53 PM
It's not portable text it's just text.
Feb 8, 2022, 9:54 PM
It's not portable text it's just text.
Feb 8, 2022, 9:54 PM
Our designer would just copy and paste his HTML.
Feb 8, 2022, 9:55 PM
I'm slowly converting things over but in the meantime...
Feb 8, 2022, 9:56 PM
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.
Feb 9, 2022, 7:36 AM
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.
Feb 9, 2022, 7:38 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.