-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Improve error messages when @apply
fails
#18059
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e2af578
to
e285dd8
Compare
e285dd8
to
f5ceae3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a note about the stylesheet name but I'm gonna go ahead and approve this. We can tweak those details later if need be.
If we do this _before_ handling `@apply`, then we won't be able to find a `@tailwind utilities` at-rule.
3b6f2c2
to
75bdb44
Compare
…"tailwindcss"` This is a better single source of truth because `Theme` will be filled in with the necessary data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback — still needs to be reviewed by @adamwathan, so don't merge anything in yet.
Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
Approved via Discord
This PR improves error messages when
@apply
fails. Right now it gives you a generic error message that you cannot apply a certain utility.Would result in:
However, there are some situations where we can give you more context about what's happening.
Missing
@import "tailwindcss"
or@reference
If you are in a Vue file for example, and you have the following code:
Then this will now result in:
We do this by checking if we found a
@tailwind utilities
or@reference
. If not, we throw this more specific error.Explicitly excluded classes via
@source not inline('…')
Or via the legacy
blocklist
from a JS config.If you then have the following file:
Then this will now result in:
We do this by checking if the class was marked as invalid.
Applying unprefixed class in prefix mode
If you have the prefix option configured, but you are applying a non-prefixed class, then we will show the following error:
Given this input:
The following error is thrown:
Applying known utilities with unknown variants
If you have unknown variants, then we will list them as well if the base utility does compile correctly.
Given this input:
The following error is thrown:
Test plan
<style>…</style>
block using@apply
[ci-all] There are some newlines here and there, let's verify that they work identically on all platforms.