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 testand lint the project withnpm run lintThis should resolve #7504. I added a check for
this.node.name === 'layer'inside theapplymethod ofAtRule.Let me know if there's anything else I should do. Thanks!