-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
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
[Svelte 5] Invalid CSS generated from Tailwind class names including [&
and url(
#14082
Comments
This comes from our attribute escaping, because |
It is: document.body.innerHTML = `<div class="&"></div>`;
document.querySelector('div').className; // '&'
document.body.innerHTML = `<div class="!"></div>`;
document.querySelector('div').className; // '!' So — reluctantly — our escaping logic needs to get smart enough to handle this edge case. |
I think you should move your tailwind vite plugin before sveltekit in your vite config |
If I put the tailwind plugin before the sveltekit plugin, as suggested by @paoloricciuti , this works. Is there any reason you can't do that? |
@paoloricciuti @dummdidumm Changing the order like |
Please provide an updated reproduction then - the given one causes no such error when changing the order. |
@saadeghi in case you didn't notice the message - we need a reproduction that also fails when switching the order |
Tried again, changing the order worked. Thanks! Should I close this issue? or… |
The order of the plugins is important in vite. In this case you want to check the classes before anything touches them so I would close the issue. What do you think @dummdidumm ? |
As pointed out the order of plugins in Vite is important, so to me that's not a workaround but the proper solution. Therefore closing this for now - I asked a clarifying question regarding this in the related tailwind issue |
Describe the bug
@tailwindcss/vite@alpha
gives Vite error if[&_div]:flex
class name andurl()
from a Tailwind plugin exists in app together.✅ Having a Tailwind plugin like this works as expected
✅ An arbitrary class name like
[&_div]:flex
works as expected.❌ But having both in the same project using
@tailwindcss/[email protected]
causes Vite error:✅ This wasn't an issue in Tailwind CSS 3 or in Svelte 4
✅ The issue doesn't happen with
@tailwindcss/[email protected]
It was really hard to debug for me because Vite just says
Unknown word
. No more details. After days I found that arbitrary class names with[]
and&
cause the issue if there's a plugin includingurl()
with encoded image in it.additional info from @thecrypticace
Reproduction
https://github.com/saadeghi/tw4alpha-vite-url-bug
it's an empty Vite/Svelte project.
There's
[&_div]:flex
class insrc/routes/+page.svelte
There's a Tailwind plugin in
src/myplugin.js
Logs
Severity
blocking all usage of svelte
The text was updated successfully, but these errors were encountered: