u
This commit is contained in:
13
src/main.jsx
13
src/main.jsx
@@ -37,6 +37,19 @@ if (import.meta.env.DEV) {
|
||||
void clearDevServiceWorker();
|
||||
}
|
||||
|
||||
// PWA auto-update: reload the page as soon as a new build's service worker
|
||||
// takes control. The virtual module only exists in production builds (the
|
||||
// plugin is registered for `build` only), hence the dynamic import.
|
||||
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
|
||||
import('virtual:pwa-register')
|
||||
.then(({ registerSW }) => {
|
||||
registerSW({ immediate: true });
|
||||
})
|
||||
.catch(() => {
|
||||
// No SW in this build — app still works, just without offline support.
|
||||
});
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<ThemeProvider theme={getActiveTheme()}>
|
||||
<CssBaseline />
|
||||
|
||||
Reference in New Issue
Block a user