-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Unused CSS selector "*" #988
Comments
Looks like it's may be related to svelte 5 : sveltejs/svelte#13399 |
Sometimes it is needed, check this example.
But with this code I get the warning: |
svelte can be used outside of vite where you might not have other means to define global styles. The warning for the * selector is a bit of an unfortunate sideeffect that only happens with components that don't have targetable nodes in their own template - and only during development. You can easily silence this warning using the new svelte5 compilerOptions: {
warningFilter(w){
return w.message !== 'Unused CSS selector "*"'
}
}, or the more generic onwarn(w, warn){
if(w.message !== 'Unused CSS selector "*"') {
warn(w)
}
} |
Ok, but i don't really think it's an argument as Ok for the compiler option, but let's say I am building a package with some components dependencies I need to style , then people using it will have multiple warnings for something they don't know about. I feel like if I am following at 100% documentation I should not have warnings. |
esp. libraries should always use scoped style or ship global styles as external css file. users projects won't see a warning for libraries with this issue as they don't get the * selector injected. |
Describe the bug
Using global in svelte style tag throw a warning :
Unused CSS selector "*"
but no rules like these are defined.Using Svelte 5, I don't know if it could be related.
The component :
Same error with a global attribute on the style tag instead of
:global()
with svelte-preprocessReproduction URL
https://github.com/bienoubien-studio/svelte-preprocess-unused-css-issue
Reproduction
Then visit http://localhost:5173
Logs
[vite-plugin-svelte] src/lib/label/label.svelte:22:1 Unused CSS selector "*"
System Info
The text was updated successfully, but these errors were encountered: