-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[fix]: support @layer
#7514
[fix]: support @layer
#7514
Conversation
If there is useless css inside <div>hello</div>
<style>
@layer base, special;
@layer special {
div {
color: rebeccapurple;
}
+ p {
+ color: red;
+ }
}
@layer base {
div {
color: green;
}
}
</style> |
interesting! i wasn't even aware that svelte purges unused CSS! 😂 i guess scoped styles make it easier for me to notice CSS i'm not using anymore. my first thought is I don't know enough yet about my second thought is that, since |
AFAIK @geoffrich Do you have opinion/thought? |
Yeah, I would expect unused CSS inside Thanks for the quick PR @kindoflew! <script>
let name = 'world';
</script>
<h1>Hello {name}!</h1>
<style>
/* Warning: Unused CSS selector "h2" (8:2) */
@media (min-width: 300) {
h2 {
color: red;
}
}
</style> |
@geoffrich As far as I can tell, it is happening for free! I just added an unused CSS rule to my test example locally and ran it and it still passed. Should I push that as well, just to cover the case? |
Perfect! I don't think we need to include it in the test case. Looking at the other |
Oh is it! Awesome! |
Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint
This should resolve #7504. I added a check for
this.node.name === 'layer'
inside theapply
method ofAtRule
.Let me know if there's anything else I should do. Thanks!