-
-
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
fix(css): remove css-post plugin sourcemap #9914
Conversation
For anyone trying to wrap their had around this, like I did, here's what I've figured:
At this point the issue is two fold:
The good thing is however that the css code wrapped into a variable inside the HMR JS response already includes the sourcemap for the CSS, so there is really no need to add the same sourcemap at the end of the HMR JS file too. This is what the fix relies on: by not only returning the new HMR JS code, but an empty dummy source map as well, it forces the source maps collected in the context so far to be ignored when the source maps are combined. The empty sourcemap masks the others, so no sitemap is generated at the end so the response is sent to the browser as it is, without additional source map attached to the end, what is done for most responses otherwise. The issue in theory is there both when And finally why the sourcemap is not needed at all in the HMR JS file carrying the css payload? Because another file is already loaded by the URL So how come it worked in some browsers and not in others? It is because some browsers ignored the sourcemap from the css request and relied on the other one provided in the other request. After all these requests are for the same file, only differ in query parameters, and there's no standard approach what to do if multiple request claim to provide mappings for a given source. Chrome tries to apply all of them. Firefox processes both sourcemaps and shows two versions of the same source, one based on each. And I assume Safari simply ignores the later one. |
Compatibility was broken with fix vitejs#9914 but also we don't need and don't want to add dummy sourcemaps to HMR JS requests.
Description
fixes #9830
/src/components/HelloWorld.vue
has the sourcemap below./src/components/HelloWorld.vue?vue&type=style&index=0&scoped=true&lang.postcss
has the sourcemap below./src/components/HelloWorld.vue
'ssourcesContent
has correct content but/src/components/HelloWorld.vue?vue&type=style&index=0&scoped=true&lang.postcss
has a empty lines for non-style part.Actually, this sourcemap comes from vite-plugin-vue2 and needs a fix on their side.
That said,
vite:css-post
does not need to return sourcemap as the sourcemap is injected inside CSS. So I removed it by settingmap: { mappings: '' }
.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).