Integrate PWA service worker registration using virtual:pwa-register.

This commit is contained in:
geoffsee
2025-07-17 13:00:16 -04:00
committed by Geoff Seemueller
parent f055cd39fe
commit 36f8fcee87

View File

@@ -1,4 +1,6 @@
// runs before anything else // runs before anything else
import { registerSW } from 'virtual:pwa-register';
import UserOptionsStore from '../stores/UserOptionsStore'; import UserOptionsStore from '../stores/UserOptionsStore';
UserOptionsStore.initialize(); UserOptionsStore.initialize();
@@ -6,7 +8,11 @@ UserOptionsStore.initialize();
try { try {
const isLocal = window.location.hostname.includes('localhost'); const isLocal = window.location.hostname.includes('localhost');
if (!isLocal) { if (!isLocal) {
navigator.serviceWorker.register('/service-worker.js'); if ('serviceWorker' in navigator) {
// && !/localhost/.test(window.location)) {
registerSW();
}
// navigator.serviceWorker.register('/service-worker.js');
} else { } else {
(async () => { (async () => {
await navigator.serviceWorker.getRegistrations().then(registrations => { await navigator.serviceWorker.getRegistrations().then(registrations => {