Skip to content

fix: resolve bare CSS @import specifiers in Tailwind CSS v4#23581

Draft
mcollovati wants to merge 2 commits intomainfrom
issues/23560-tailwind_styles_relative_path_error
Draft

fix: resolve bare CSS @import specifiers in Tailwind CSS v4#23581
mcollovati wants to merge 2 commits intomainfrom
issues/23560-tailwind_styles_relative_path_error

Conversation

@mcollovati
Copy link
Collaborator

Tailwind CSS v4's Vite plugin fails to resolve bare @import specifiers (e.g. @import "other.css" without ./) in CSS files located within project static asset folders. Add a Vite plugin that hooks into Tailwind's __tw_resolve to resolve bare CSS specifiers by checking if the importing file is inside a known static asset folder and resolving the specifier relative to that location.

Add integration test in test-tailwindcss that verifies a bare @import inside a @CssImport-referenced CSS file resolves correctly when processed through the Tailwind CSS pipeline.

Fixes #23560

Tailwind CSS v4's Vite plugin fails to resolve bare `@import` specifiers
(e.g. `@import "other.css"` without `./`) in CSS files located within
project static asset folders. Add a Vite plugin that hooks into
Tailwind's `__tw_resolve` to resolve bare CSS specifiers by checking
if the importing file is inside a known static asset folder and
resolving the specifier relative to that location.

Add integration test in test-tailwindcss that verifies a bare
`@import` inside a `@CssImport`-referenced CSS file resolves correctly
when processed through the Tailwind CSS pipeline.

Fixes #23560
@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Test Results

 1 360 files  + 1   1 360 suites  +1   1h 26m 17s ⏱️ + 1m 9s
 9 644 tests + 1   9 577 ✅ +1  67 💤 ±0  0 ❌ ±0 
10 088 runs   - 10  10 015 ✅  - 7  73 💤  - 3  0 ❌ ±0 

Results for commit 9b1409b. ± Comparison against base commit 234f071.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link

@github-actions github-actions bot added +0.0.1 and removed +1.0.0 labels Feb 19, 2026
Comment on lines +599 to 600
bareCssImportResolver(),
//#tailwindcssVitePlugin#
Copy link
Contributor

Choose a reason for hiding this comment

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

If we would ad this fix then the baseCssImportResolver() should probably be added in the replacement of //#tailwindcssVitePlugin# instead of always being there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it makes sense.
I did it previously, but the Java task class had some awful code to preserve indentation, like hard-coded spaces.
It can probably be done in a better way, by using a regex or by reading the whole placeholder line before replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PiT 25.1: Tailwind CSS plugin fails to resolve relative @import "theme-editor.css" in styles.css

2 participants