-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
CSS minification warnings don't contain file names, making them difficult to track down #15915
Comments
Also stuck on this error recently.
However, I'm unable to find anywhere that would explain this in our application. All of the scss files we have seem to appear correct, and most our other styling is through any 3rd party packages (like tailwind), so tracing down is about impossible without knowing more details. I can see a PR was created, but hasn't had any traction for a couple weeks. |
Are you using CSS modules by chance? I seem to recall that's where I was seeing it the most. Seems like it would drop Specifically the following: :global {
.bar {
color: blue
}
} I can't pretend that I'm too familiar with the CSS Modules spec, but this syntax is supported elsewhere but not by Vite. |
@rschristian I do have 1 module file that has a :global reference. Commenting that out does seem to fix it in this case, but I definitely would have never thought of that, especially since this is supported in other non-vite apps I've worked with just fine. |
For the above example, that can be switched to the following to fix it: :global(.bar) {
...
} I was only able to find this as the error message was pointing to a rather high line count (484) that only a few of our files hit. Went one-by-one until I found the culprit. |
Thanks for the tip! That will work for our case for the immediate fix. |
Description
Currently, I'm looking a CSS minification warning that looks like this:
This is fairly difficult to track down, as the user needs to go one-by-one to try to figure out which module has an open brace on line 484.
Sometimes this is easier to track down, given a class name or a bit of syntax is shown in the warning, like in the following:
Position info is again pretty hard to use, but the content is at least something we can grep for without too much trouble.
This particular warning can be reproduced with the following CSS content, if it's helpful:
Just stick a
<link rel="stylesheet" href"./style.css">
in the HTML entry and you're good to reproduce.(I fully appreciate this is pretty nasty CSS, I'm working to migrate some old LESS and this is what I'm workin' with at the moment)
Suggested solution
If possible, a file name in the warning message would be ideal, else, perhaps some more context in the warning, like the line above & below?
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: