Don't rewrite source maps for @layer
rules
#8971
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since we generate utilities on demand the source maps point back to the corresponding
@tailwind
directive for that rule. For example, the component.container
points back to the@tailwind components
at-rule.We would do this unconditionally for all generated output by Tailwind CSS. Since
@layer components
and@layer utilities
in CSS register custom utilities, the source maps for these could be lost when the files containing the@layer
and@tailwind
directives were different. This happens when using postcss-import for example:Because of this we would throw away the original source information and it appeared, to later tools, that the original source map was just
@tailwind components
from thecomponents.css
file instead of having sources fromcomponents.css
AND frominput.css
. This in turn broke Vite's url-rewriting because it relies on the original source map input.Curiously, with postcss-import, this problem doesn't appear for local CSS file imports. Only imports coming from
node_modules
(unless I did something wrong 🙃 ). I would have expected it to rewrite the rules from inside the CSS file to point to the@import
but perhaps it treats node_modules stuff differently.In any case, this PR fixes the source maps so that rules generated from
@layer
point back to the original source.Fixes #8966