You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perform custom HMR update handling. The hook receives a context object with the following signature:
407
408
@@ -423,10 +424,31 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo
423
424
424
425
- Filter and narrow down the affected module list so that the HMR is more accurate.
425
426
426
-
- Return an empty array and perform complete custom HMR handling by sending custom events to the client (example uses `server.hot` which was introduced in Vite 5.1, it is recommended to also use `server.ws` if you support lower versions):
427
+
- Return an empty array and perform a full reload:
428
+
429
+
```js
430
+
handleHotUpdate({ server, modules, timestamp }) {
431
+
// Also use `server.ws.send` to support Vite <5.1 if needed
432
+
server.hot.send({ type:'full-reload' })
433
+
// Invalidate modules manually
434
+
constinvalidatedModules=newSet()
435
+
for (constmodof modules) {
436
+
server.moduleGraph.invalidateModule(
437
+
mod,
438
+
invalidatedModules,
439
+
timestamp,
440
+
true
441
+
)
442
+
}
443
+
return []
444
+
}
445
+
```
446
+
447
+
- Return an empty array and perform complete custom HMR handling by sending custom events to the client:
427
448
428
449
```js
429
450
handleHotUpdate({ server }) {
451
+
// Also use `server.ws.send` to support Vite <5.1 if needed
0 commit comments