fix(react-email): preserve local CSS variable overrides

MO
7d ago
+143-17

Closes #3794.

A custom utility that overrides a theme variable currently renders with the earlier root value. For example, a blue local --color-brand becomes red in the email's inline style.

Select the winning declaration in the same block before falling back to global definitions. Preserve existing direct !important matching and nested-rule checks. Index local definitions once; this does not implement the full CSS cascade.

Validation on Windows with Node 24 and pnpm 11:

  • 158 Tailwind tests pass, including local overrides, declaration order, important defaults and public rendering.
  • pnpm lint, pnpm --filter react-email typecheck and pnpm --filter react-email build pass.
  • The minimal reproduction fails on 6.11.3 and passes against the built, installed tarball.
  • Full package suite: 325 pass, 4 fail. The same four CLI export/path assertions fail on untouched code; no new failures. They concern plugin process exit, two dynamic-import alias cases and root-directory matching.

Summary by cubic

Fixes local theme-variable overrides in custom utilities being ignored in favor of earlier global defaults.

  • Selects the winning declaration within the same block before falling back to global definitions.
  • Preserves existing !important matching and nested-rule checks.
  • Indexes local definitions once rather than implementing the full CSS cascade.