Skip to content

Commit

Permalink
fix: Vite 5 HMR not working (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Dec 27, 2023
1 parent 8303945 commit 959eae9
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,17 @@ export function manifestLoaderPlugin(options: ResolvedOptions): vite.Plugin {
noInput.cleanupBundle(bundle);
},

// Runs during: watch
// Runs during: watch, dev
async watchChange(id) {
if (!browserOpened || id.startsWith(paths.outDir)) return;
if (
// Only run this hook for `vite build --watch`, not `vite dev`
mode === BuildMode.DEV ||
// Don't reload if the browser isn't opened yet
!browserOpened ||
// Don't reload if the change was a file written to the output directory
id.startsWith(paths.outDir)
)
return;

const relativePath = path.relative(paths.rootDir, id);
logger.log(
Expand Down

0 comments on commit 959eae9

Please sign in to comment.