Conversation
|
I guess changing if (!hmrContext.modules.length) {
// html file cannot be hot updated
if (file.endsWith('.html')) {
config.logger.info(colors.green(`page reload `) + colors.dim(shortFile), {
clear: true,
timestamp: true
})
ws.send({
type: 'full-reload',
path: config.server.middlewareMode
? '*'
: '/' + normalizePath(path.relative(config.root, file))
})
} else {
// loaded but not in the module graph, probably not js
debugHmr(`[no modules matched] ${colors.dim(shortFile)}`)
}
return
}to // html file cannot be hot updated
if (file.endsWith('.html')) {
config.logger.info(colors.green(`page reload `) + colors.dim(shortFile), {
clear: true,
timestamp: true
})
ws.send({
type: 'full-reload',
path: config.server.middlewareMode
? '*'
: '/' + normalizePath(path.relative(config.root, file))
})
return
}
if (!hmrContext.modules.length) {
// loaded but not in the module graph, probably not js
debugHmr(`[no modules matched] ${colors.dim(shortFile)}`)
return
}is better. (I'm not sure if I'm correct.) |
|
I'm running into a slightly different issue, but the fix is the same. Is there a good reason not to add the path that caused the full-reload to the |
bluwy
left a comment
There was a problem hiding this comment.
I think the current PR is fine by me, but probably be safer if we do it like this too:
vite/packages/vite/src/node/server/hmr.ts
Lines 203 to 208 in c3b3d3c
Regarding sapphi's comment, I suppose if the HTML was ever in the hmrContext.modules, it may be safer to invalidate the modules anyway to prevent potential issues with tailwind.
With the updated understanding over the last two years, I agree with that. 😅 |
|
I think we should close this one as stale, @sibbng @philipp-spiess if this is still an issue in Tailwinds v4, would you create an issue so we can properly track this? And you can send a new PR to continue this discussion against it in that case. |
Description
I'm working on a Tailwind project, when I update an
htmlfile that is tracked by Tailwind, Vite full-reloads all pages.If files are tracked by Tailwind they bypass this check:
vite/packages/vite/src/node/server/hmr.ts
Line 105 in a9ccedd
In my case,
hmrContext.modulesis:hmrContext.modules
When they bypass here, they fall into here:
vite/packages/vite/src/node/server/hmr.ts
Lines 164 to 171 in a9ccedd
Which is the source of problem. This part of code doesn't send
pathto full-reload events and this cause full reload on all pages:vite/packages/vite/src/client/client.ts
Lines 116 to 131 in a9ccedd
I assume this is what happened to @cdauth, as he described in #6695:
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).