Skip to content

Conversation

gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Feb 25, 2025

Closes #1871. The issue there is pretty clear on what the problem they were having was, the problem particularly was that the internal candidateRuleCache from Tailwind was not being cleared. This pull request also adds in a test to ensure that this is working and that there are no future regressions on this.

tailwindContext.candidateRuleCache = new Map();

The above line is the actual fix, it literally sets the cache as empty before doing any of the class-to-style resolution.

The specific issue was that the first time a class like dark:... (i.e., a class to insert into the user's <Head>), it worked just fine, but then the second time the same exact class was used again, it seems to simply ignore it, and not do the transformations that are needed.

Copy link

changeset-bot bot commented Feb 25, 2025

🦋 Changeset detected

Latest commit: 845dae5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@react-email/tailwind Patch
@react-email/components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Feb 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2025 7:07pm
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2025 7:07pm

@gabrielmfern gabrielmfern force-pushed the canary branch 4 times, most recently from addf436 to ade5f69 Compare June 16, 2025 14:07
@gabrielmfern gabrielmfern force-pushed the canary branch 4 times, most recently from 3ff8597 to 3c4ea0a Compare June 30, 2025 13:13
@gabrielmfern gabrielmfern force-pushed the fix/tailwind-not-extracting-media-queries branch from 75f1cab to 7c5cd2a Compare July 10, 2025 15:49
@gabrielmfern gabrielmfern changed the base branch from canary to main July 10, 2025 15:50
Copy link

pkg-pr-new bot commented Jul 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/tailwind@1929

commit: 845dae5

@gabrielmfern gabrielmfern changed the title fix(tailwind): Color-scheme media queries not getting sanitized sometimes fix(tailwind): color-scheme media queries not getting sanitized sometimes Jul 10, 2025
@gabrielmfern gabrielmfern changed the title fix(tailwind): color-scheme media queries not getting sanitized sometimes fix(tailwind): media queries not getting sanitized sometimes Jul 10, 2025
Copy link

@pedro-stramantinoli pedro-stramantinoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@gabrielmfern gabrielmfern merged commit 86e66d8 into main Jul 11, 2025
14 checks passed
@gabrielmfern gabrielmfern deleted the fix/tailwind-not-extracting-media-queries branch July 11, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tailwind color-scheme media classes are only added on body tag
2 participants