From a5e6c9784c67b3c1bdf53c98afc575e83351bc64 Mon Sep 17 00:00:00 2001 From: lazarv Date: Tue, 4 Jun 2024 23:57:39 +0200 Subject: [PATCH] fix: use environment config root for hmr filename --- packages/vite/src/node/server/hmr.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 2d5b8484052d86..3137986038c479 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -203,7 +203,7 @@ export async function handleHMRUpdate( // (dev only) the client itself cannot be hot updated. if (file.startsWith(withTrailingSlash(normalizedClientDir))) { - environments.forEach(({ hot }) => + environments.forEach(({ config, hot }) => hot.send({ type: 'full-reload', path: '*', @@ -370,9 +370,10 @@ export async function handleHMRUpdate( ) environment.hot.send({ type: 'full-reload', - path: config.server.middlewareMode + path: environment.config.server.middlewareMode ? '*' - : '/' + normalizePath(path.relative(config.root, file)), + : '/' + + normalizePath(path.relative(environment.config.root, file)), }) } else { // loaded but not in the module graph, probably not js @@ -383,7 +384,7 @@ export async function handleHMRUpdate( return } - updateModules(environment, shortFile, context.modules, timestamp) + updateModules(environment, file, context.modules, timestamp) } catch (err) { environment.hot.send({ type: 'error',