@wii/fastify-webpack
Version:
fastify plugin for webpack
24 lines (18 loc) • 647 B
text/typescript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const hot = import.meta.webpackHot || module.hot;
const eventSource = new EventSource('/__fastify_webpack_hot');
eventSource.addEventListener('sync', async (event) => {
const syncEvent = JSON.parse(event.data);
// console.log(syncEvent);
console.log('[fastify-webpack] bundle updated %s', syncEvent.hash);
if (hot?.status() === 'idle') {
try {
await hot.check(true);
} catch (error) {
console.error(error);
console.error('[fastify-webpack] could not complete check, full reload page');
window.location.reload();
}
}
});