Skip to content

Fix minified CSS variable extraction, add build integration tests#34

Merged
retlehs merged 5 commits intomainfrom
fix/minified-css-variable-extraction
Mar 11, 2026
Merged

Fix minified CSS variable extraction, add build integration tests#34
retlehs merged 5 commits intomainfrom
fix/minified-css-variable-extraction

Conversation

@retlehs
Copy link
Member

@retlehs retlehs commented Mar 11, 2026

Summary

  • Fix regex bug — The [;}]? trailing each CSS variable extraction pattern consumed the delimiter that the next match needed for its (?:^|[;{}]) anchor. In minified CSS (single line), this caused every other variable to be skipped — e.g. only 6 of 11 color shades extracted. Affects --color-*, --font-*, --text-*, and --radius-* patterns.
  • Add build integration tests — New test suite (tests/build.test.ts) that runs a real vite build with Tailwind against a minimal theme fixture (tests/fixture/) and verifies the generated theme.json output. Covers color palette completeness, color families, font families, font sizes, border radius, and disable flags.

Regression

Introduced in v1.3.0 via #33 when the regex patterns were updated to filter out namespace wildcard resets. The (?:^|[;{}]) prefix was added correctly, but the existing [;}]? suffix became a problem — in minified CSS it consumes the ; separator, starving the next match's anchor.

Test plan

  • npx vitest run — all 64 tests pass (58 existing unit tests + 6 new integration tests)
  • Verified against a Sage theme build: all 11 Tailwind color shades (50–950) now appear in theme.json

🤖 Generated with Claude Code

The regex patterns for extracting --color-*, --font-*, --text-*, and
--radius-* variables included a trailing [;}]? that consumed the
delimiter. In minified CSS (single line), this starved the next match's
(?:^|[;{}]) anchor, causing every other variable to be skipped — e.g.
only 6 of 11 color shades were extracted.

Drop the trailing [;}]? since [^;}]+ already stops before the delimiter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@retlehs retlehs self-assigned this Mar 11, 2026
retlehs and others added 4 commits March 11, 2026 14:23
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Works around npm optional dependency resolution bug (npm/cli#4828)
that causes @tailwindcss/oxide platform binaries to be missing
when installing without a lock file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Node 18 is unsupported by Tailwind v4. Adding @tailwindcss/oxide
as an explicit devDependency ensures npm installs the platform-specific
native binaries (works around npm/cli#4828).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@retlehs retlehs merged commit a98e0be into main Mar 11, 2026
3 checks passed
@retlehs retlehs deleted the fix/minified-css-variable-extraction branch March 11, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant