Always resolve relative files, relative to the current .css file#19965
Always resolve relative files, relative to the current .css file#19965RobinMalfait merged 4 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe pull request fixes relative path resolution for Tailwind CSS directives ( 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
…wn rc.17 @tailwindcss/vite 4.2.3+ spreads vite.config.resolve into a rolldown resolver-plugin config; rolldown rc.17 made tsconfigPaths a required field on BindingViteResolvePluginConfig.resolveOptions. Setting tsconfigPaths in the astro Vite config populates the field one layer up so the napi binding accepts the call. No path aliases are declared in site/tsconfig, so the resolution itself is a no-op. Vitest 4.1.5 / Vite 7.3.2 routes JSX through oxc and ignores the esbuild option; switch to the oxc.jsx config. Adds a ResizeObserver shim to test-setup so jsdom-backed component tests don't crash on ComparisonTable's ResizeObserver use. Corrects four ComparisonTable test assertions that expected SynthOrg to be filterable -- the component pins it through every filter (see ComparisonTable.tsx:188). Upstream: tailwindlabs/tailwindcss#19965 (merged), 4.2.5 not yet shipped.
This PR fixes an issue where resolving of certain CSS or JS files results in the wrong paths. The issue happens if you have a setup where a relative file path also exists in the parent folder:
This happened because we resolved relative to a
basefolder, but Vite expects animporterinstead. The difference is subtle, but they expect a file. On that file they uselet base = path.dirname(importer)to get a base path out themselves.This in turn means that if you pass in a folder, you get this:
If we gave it a proper file, then we get the proper base path
I'm actually surprised that this didn't cause issues earlier... but it did result in error since we recently started resolving files using Vite's
aliasOnly: truefeature such taht Vite aliases work as well.With this change, we now make sure that:
importerinstead of thebasepathaliasOnly: truefirst, thenaliasOnly: falseWe also still ensure that in the CSS resolver we expect a
.cssfile, and in the JS resolver we don't expect a.cssfile (which can happen if a"browser": "./dist/index.css"field in package.json points to a CSS file, daisyUI does this for example).Fixes: #19956
Test plan
While the build still worked, the linked issue resulted in a much bigger file size because the wrong .css files were included. With this fix, the number is correct again:

Since this is touching code related to previous PRs, I wanted to manually make sure that these still work as expected:
Unknown file extension ".css" for ... #19950: This one is about daisyUI and the
.cssfile referenced in the package.json's"browser"field:@tailwindcss/vite: build error when use @plugin "@tailwindcss/typography"; #19946: This one is about the Vite alias being just a single
@causing issues with@plugin "@tailwindcss/typography";for example:[ci-all]