-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(css): provide filename for css-minify error #16006
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
By concatenating CSS files before minifying, esbuild can apply cross-file optimizations. For example, duplicates can be removed (esbuild try). |
We can map the position back to the original position by using source maps. But I think it's fine to leave it for now since we don't support CSS source maps in build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
f20f1b2
to
7196772
Compare
@@ -63,7 +63,6 @@ import { | |||
removeDirectQuery, | |||
removeUrlQuery, | |||
requireResolveFromRootWithFallback, | |||
slash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this line to resolve the merge conflict. Before merging, this needs to be double checked!
@sapphi-red I think in this case, when We could use the already parsed and minized css to point to accurate point, but it that case, that css won't point to the correct source file. I don't really know how to handle the css that is parsed. |
That part is fine. If I append the following content to {
color: blue;
} I get [
...,
{
file: 'vite/playground/css/stylus.styl',
end: 151
},
{
file: 'vite/playground/css/mod.module.css',
end: 159
},
...
] The file exists in |
Yes, you are right. I found out that I should've just went with 1-based number count and shouldn't have concat the css with |
decb993
to
39838f2
Compare
No problem 😃 Don't we always need to append a line break at the end? Otherwise, we'll have more than one file mapped to a line and then we cannot map the line back to the original file. For example, if the |
Yeah.. Just concating is vague to map back.. I changed all the concating logic back to concating with |
e44542c
to
4476b9e
Compare
4476b9e
to
00e1b76
Compare
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ analogjs, astro, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, remix, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-setup-catalogue, vitepress |
Description
Previously, css code were concatenated into one string and then passed to
finalizeCss()
which made it hard to track where the error came from. So, I made an intermediary map to store the filename (id
) with the code and passed that filename tofinalizeCss()
to give the user context when it errors.Additional context
Instead of passing one giant css string to
finalizeCss()
, I tried to break it down and pass each filename to make the error more elegant. It is passing the test but because I am finalizing the css code by file and then concatenating, the result of hoisting might not be as same as before.I don't think it will be a big problem, but I'll try to add a e2e test to check if this change will break anything.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).