Files
crowd-funder-for-time-pwa/src/registerServiceWorker.ts
Matthew Raymer 26f303bae9 Enable full PWA install experience in all web modes
- Add PWAInstallPrompt component for custom install UI and event handling
- Register PWAInstallPrompt in App.vue for global visibility
- Enable PWA features and install prompt in dev, test, and prod (vite.config.web.mts)
- Update service worker registration to work in all environments
- Update docs/build-web-script-integration.md with PWA install guidance and visual cues
- Add scripts/build-web.sh for unified web build/dev workflow

PWA is now installable and testable in all web environments, with clear user prompts and desktop support.
2025-07-11 04:41:38 +00:00

38 lines
1.0 KiB
TypeScript

/* eslint-disable no-console */
import { register } from "register-service-worker";
// Register service worker if PWA is enabled
// Enable in all environments for consistent testing and functionality
if (process.env.VITE_PWA_ENABLED === "true") {
register(`${process.env.BASE_URL}sw.js`, {
ready() {
console.log("Service worker is active.");
},
registered() {
console.log("Service worker has been registered.");
},
cached() {
console.log("Content has been cached for offline use.");
},
updatefound() {
console.log("New content is downloading.");
},
updated() {
console.log("New content is available; please refresh.");
},
offline() {
console.log(
"No internet connection found. App is running in offline mode.",
);
},
error(error) {
console.error("Error during service worker registration:", error);
},
});
} else {
console.log(
`Service worker registration skipped - PWA not enabled (VITE_PWA_ENABLED=${process.env.VITE_PWA_ENABLED})`,
);
}