-
Notifications
You must be signed in to change notification settings - Fork 71
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
DIsable css "css-unused-selector" warning #67
Comments
This would be a great feature - if you're using a third-party library, you get thousands upon thousands of warning every time the application hot-reloads. |
👍 |
@tborychowski |
@antony haha! you're joking right? |
@tborychowski no, just don't have my brain switched on! I was thinking about the html structure instead of the css rules :) Yeah, it makes sense that |
This issue seems to be about multiple things now. There is already a way to suppress There is a way to prevent Svelte's automatic scoping and removal of a selector, and that's with I'm not sure how much would be involved in getting the compiler to recognize that I'm going to close this, since the original question ('how can I disable this warning?') already has an answer. |
Hate to open this, but i really don't get where i am supposed to set this onwarn option. |
It's mentioned in the Rollup plugin readme here - and its usage is the same in this loader - but it should probably be added to this readme as well. |
By overriding my webpack.config.js I just get that "onwarn" is not a option property, and as far as I can see in the code it is true and there is not handler for this option. config.module.rules[svelteIndex].options.onwarn = (warning, onwarn) =>
warning.code === 'Unused CSS selector' || onwarn(warning); The loader seems not to load onwarn function in Svelte >= 3.0 or that is my believe from the code https://github.com/sveltejs/svelte-loader/blob/master/index.js#L124 Any idea how it should work? or is really missing? |
Yeah it turned out there was a bug here, which I've opened #105 for. |
Thank you @Conduitry, temporally I added your changes in my local instance and it works as expected. Thank you so much. very easy and yet useful update. |
Just for the record, the code snippet by @Egnus (#67 (comment)) should be either config.module.rules[svelteIndex].options.onwarn = (warning, onwarn) =>
warning.message === 'Unused CSS selector' || onwarn(warning);
^ message instead of code or config.module.rules[svelteIndex].options.onwarn = (warning, onwarn) =>
warning.code === 'css-unused-selector' || onwarn(warning);
^ or this selector |
If it's helpful to anyone, I tired of the "Unused CSS selector" warnings and, following the links in this thread, found a small change was required. The following code silences these warnings - within rollup.config.js, in the client object place this code:
|
I had to slightly modify the examples here since I'm ignore other warnings as well... leaving it here in case it's useful to anyone else (including myself) in the future... in
|
I tried all the suggestions in this thread and none worked. It seems I have a different version of the message. I finally made it work using a regular expression instead of a const onwarn = (warning, onwarn) =>
(warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) ||
(warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
(/Unused CSS selector/.test(warning.message)) ||
onwarn(warning); |
this is my webpack config. it works
|
We should, obviously, rather just clean up the CSS. But for now, the warnings are spamming the console to the point where actual debugging is impossible: debug statements and logging is drowned in this noise. From sveltejs/svelte-loader#67
I'm not sure how unused rules are treated., but according to sveltejs/svelte#729 it's removed?
My problem is I'm using scss and a lot of things get imported, so a lot of unused rules appear as a side effect. Is there no way to disabled those
css-unused-selector
warnings? ThanksThe text was updated successfully, but these errors were encountered: