-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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 loaded from body fails to hot reload #469
Comments
I test that link css within body and the hmr work fine. |
Thanks for checking. I should have been more clear in my title/description: HMR is occurring--style changes are being injected, but they're injected in a way that doesn't override existing styles when the In my example, My sole style in the body link tag is this.
If you change it to this
the updated style gets injected in the |
I found that Vite has some puzzling behaviour around stylesheets. Like you, I tried to import a stylesheet using a |
This is a hack that fixes my problem for now, live updating css that's a Considering this in the
And this section Lines 109 to 114 in 2b87b1d
I added this this above line 112 // find a <link> with the path
const el = document.querySelector(`link[href*='${path}']`);
// add a timestamp to the path and the styles are properly refreshed
if (el) {
el.setAttribute('href', `${path}&t=${timestamp}`);
} |
Describe the bug
CSS loaded via
<link href />
within<body/>
fails to hot reload. While putting stylesheets in the<head />
is best practice, our environment does not allow this. Vite puts stylesheet updates in the<head />
regardless so it does not override stylesheets below it. I would expect vite to:<head />
href
so the browser refreshes the stylesheet directly (browsersync does this).<link rel="stylesheet" href="/src/test.css?TIMESTAMP"/>
Reproduction
Please provide a link to a repo that can reproduce the problem you ran into.
https://github.com/briantjacobs/test_vite
Steps taken in repo:
test.css
tosrc
folder:background:red
and save. Only manual reloads refresh the stylesheet. Moving the<link/
> to<head/>
and hot reload works great.System Info
vite
version: 1.0.0-beta.3vue
version (fromyarn.lock
orpackage-lock.json
)@vue/compiler-sfc
versionLogs (Optional if provided reproduction)
vite
orvite build
with the--debug
flag.The text was updated successfully, but these errors were encountered: