Files
myprojplanet_vite/src-pwa/register-service-worker.js
Surya Paolo bc960d38a1 PASSAGGIO A VITE !
AGG. 1.1.23
2025-03-01 14:14:43 +01:00

39 lines
1.3 KiB
JavaScript
Executable File

/*
* This file is picked up by the build system only
* when building for PRODUCTION
*/
import { register } from 'register-service-worker'
register(import.meta.env.VITE_SERVICE_WORKER_FILE ? import.meta.env.VITE_SERVICE_WORKER_FILE : '', {
scope: '/',
ready() {
console.log('READY::: App is being served from cache by a service worker ' + import.meta.env.VITE_SERVICE_WORKER_FILE)
},
registered(registration) { // registration -> a ServiceWorkerRegistration instance
console.log('REGISTERED::: !!!', import.meta.env.VITE_SERVICE_WORKER_FILE)
},
cached(registration) {
console.log('CACHED::: Content has been cached for offline use.')
},
updatefound(registration) {
console.log('UPDATEFOUND::: New content is downloading.')
// $('#newvers').addClass('btnNewVersShow').removeClass("btnNewVersHide")
},
updated(registration) {
document.dispatchEvent(
new CustomEvent('swUpdated', { detail: registration })
)
console.log('New content is available; please refresh.')
},
offline() {
console.log('No internet connection found. App is running in offline mode.')
},
error(err) {
console.error('Error during service worker registration:' + err)
},
});
// ServiceWorkerRegistration: https://developer.mozilla.org/enUs/docs/Web/API/ServiceWorkerRegistration