u
This commit is contained in:
17
src/main.jsx
17
src/main.jsx
@@ -11,6 +11,8 @@ import { installCssVars } from './colors';
|
||||
// Side-effect imports: each module registers its automat and subscribes to
|
||||
// authAutomat, so the stores must be evaluated before the session bootstraps.
|
||||
import './automats';
|
||||
import { initPwa } from './automats';
|
||||
import PwaUpdateDialog from './components/PwaUpdateDialog';
|
||||
import './index.css';
|
||||
|
||||
// Publish the color tokens as CSS custom properties so index.css (and any
|
||||
@@ -37,18 +39,8 @@ 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.
|
||||
});
|
||||
}
|
||||
// Initialize PWA service worker registration and update listener in production
|
||||
initPwa();
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<ThemeProvider theme={getActiveTheme()}>
|
||||
@@ -71,6 +63,7 @@ createRoot(document.getElementById('root')).render(
|
||||
</Suspense>
|
||||
) : null}
|
||||
</Box>
|
||||
<PwaUpdateDialog />
|
||||
</AuthBootstrap>
|
||||
</SnackbarProvider>
|
||||
</ThemeProvider>,
|
||||
|
||||
Reference in New Issue
Block a user