fix(react-email): resolve theme variables used inside Tailwind utility variables
Closes #3801.
Gradients, shadow/ring colors, blur-*, drop-shadow-* and translate-* with theme values inlined var(--color-…)/var(--spacing), which email clients drop because nothing defines them. Arbitrary values and direct utilities were fine. The broken ones go through Tailwind's --tw-* variables.
resolveAllCssVariables had two gaps:
- It never looked for
var()inside custom property values, so--tw-gradient-from: var(--color-red-500)was never resolved against:root. css-tree parses custom property values asRaw, so they're parsed as values before walking. - It cached each definition as a string at collection time, so a later use, like
filter: var(--tw-blur,), got the unresolved text. Replacements now read the definition's current value.
A var() inside a custom property that has no matching definition keeps its fallback. Another class on the element may still define it at inline time. For example, shadow-red-500 sets --tw-shadow-color for shadow-md's --tw-shadow. Substituting the fallback early would break that.
Most of the diff in resolve-all-css-variables.ts is re-indentation from dropping the else. Use ?w=1 to see the real change.
Not addressed: shadow-black/20 still leaves a color-mix(in oklab, rgb(0,0,0,0.2) 100%, transparent) after resolution. That's a separate color-mix downleveling issue.
Tests
- A resolver unit test for
var()inside custom property definitions and the stale-definition case (--tw-blur). - A
<Tailwind>render test covering a three-stop theme gradient, themeshadow-*/ring-*colors,blur-smandtranslate-x-2, which asserts novar(in the output. - Both fail on
canaryand pass with the fix. No existing snapshot changed. pnpm testinpackages/react-email(316 passed),pnpm typecheckandpnpm lintall pass locally.
This doesn't conflict with #3795, which touches the same file: it applies cleanly on top, and the Tailwind tests pass with both.