-
-
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
importAnalysisBuild.ts
injects same CSS styles multiple times
#13169
Comments
Start a new pull request in StackBlitz Codeflow. |
I guess the problem here is this
This is because this function is used
instead of
( modulePreload.resolveDependencies is set).
|
Yes exactly. The |
Hello dear Vite maintainers. Is there any progress on this bug? |
@daniele-orlando I have the same Problem. My server already renders the link in the HTML, when the client hydrates the DOM the stylesheet link gets added a second time. export default defineConfig({
plugins: [vue()],
experimental: {
renderBuiltUrl(filename) {
// make css assets relative
if (filename.includes('.css')) {
return { relative: true };
}
}
}
}); This will make the file path relative and the |
Expected
Hydrating a React app, server side rendered through Puppeteer, I expect that CSS styles already injected inside the
index.html
file, are not injected a second time at runtime.Actual
The
preload()
function from thepackages/vite/src/node/plugins/importAnalysisBuild.ts
file is failing detecting already injected stylesheets, and injects them a second time.
A picture is worth a thousand words.
Analysis
I discovered that the check at line 110 does not handle all cases. From my test, it can be corrected changing this block.
The point is that the routine should test even the
href
attribute, and not only thehref
property.Reproduction
https://stackblitz.com/edit/vitejs-vite-qcgqrn?file=index.html
Steps to reproduce
I explain the reproduction steps inside the README of the reproduction repository here
https://stackblitz.com/edit/vitejs-vite-qcgqrn?file=README.md
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: