Skip to content

fix(vite): merge user resolve.conditions instead of overwriting them - #20429

Open
wook10 wants to merge 2 commits into
tailwindlabs:mainfrom
wook10:fix/vite-resolve-conditions-merge
Open

fix(vite): merge user resolve.conditions instead of overwriting them#20429
wook10 wants to merge 2 commits into
tailwindlabs:mainfrom
wook10:fix/vite-resolve-conditions-merge

Conversation

@wook10

@wook10 wook10 commented Aug 23, 2026

Copy link
Copy Markdown

Summary

@tailwindcss/vite's CSS resolver hardcodes conditions: ['style', 'development|production'] in two places in packages/@tailwindcss-vite/src/index.ts (the pre-Environment-API branch and the newer Environment API branch). This overwrites any resolve.conditions the user configured in their Vite config instead of merging with them, so a package that relies on a custom export condition for its CSS entry point silently falls back to the default/style export.

This PR appends the user's configured resolve.conditions (if any) to the built-in conditions at both call sites instead of replacing them.

Test plan

  • Added a regression test in integrations/vite/resolvers.test.ts using a local workspace package with a conditional CSS export, asserting that a custom resolve.conditions entry is honored by the CSS resolver during a production build.
  • CI (vite integration job) — I wasn't able to build @tailwindcss/oxide locally (no Rust toolchain in my current environment) to run the full integration suite, so I'd appreciate CI confirming this on all platforms.

Fixes #20426

@tailwindcss/vite's CSS resolver hardcodes conditions: ['style',
'development|production'], overwriting any conditions the user passed
via resolve.conditions in their Vite config instead of merging with
them. This happened in both the pre-Environment-API and Environment
API resolver branches.

Fixes tailwindlabs#20426
@wook10
wook10 requested a review from a team as a code owner August 23, 2026 05:15
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: af38a03d-e4e5-490b-b139-bc12a67a1fac

📥 Commits

Reviewing files that changed from the base of the PR and between a121d65 and dab4ebe.

📒 Files selected for processing (1)
  • integrations/vite/resolvers.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

The Vite plugin now appends user-defined resolve.conditions to its built-in CSS resolver conditions in legacy and environment-based paths. A production-build integration test runs with Vite ^8 and ^5.3.5 and verifies that the custom stylesheet is selected.

Merge Risk: ⚪ Minimal · up to dab4e

The PR preserves Vite's built-in CSS resolution conditions while honoring user-configured conditions, with a regression test covering the affected behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: merging user Vite resolve conditions instead of overwriting them.
Description check ✅ Passed The description accurately explains the resolver bug, the fix, the regression test, and the linked issue.
Linked Issues check ✅ Passed The implementation preserves user resolve conditions in both CSS resolver branches and adds regression coverage for both supported paths [#20426].
Out of Scope Changes check ✅ Passed The changes are limited to merging Vite resolver conditions and testing custom conditional CSS exports.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported legacy resolver coverage gap is addressed by an independent Vite 5.3.5 integration case, and no blocking failure remains.

Reviews (2): Last reviewed commit: "test(vite): cover legacy (pre-Environmen..." | Re-trigger Greptile

Comment thread integrations/vite/resolvers.test.ts Outdated
Greptile flagged that the regression test only exercised the newer
Environment API path (Vite 8). Parameterize it over Vite 8 and Vite
5.3.5 so both resolver branches that got the conditions-merge fix are
covered.
@wook10

wook10 commented Aug 23, 2026

Copy link
Copy Markdown
Author

Good catch — the regression test only covered the Environment API path. Pushed a follow-up commit parameterizing it over Vite 8 and Vite 5.3.5 so both resolver branches are exercised.

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.

@tailwindcss/vite discards resolve.conditions when resolving CSS @import, but honours them for JS

1 participant