Skip to content
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

fix: Vite 5 HMR not working #173

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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