You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.0 KiB

/* eslint-disable no-console */
import { register } from "register-service-worker";
// Only register service worker if explicitly enabled and in production
if (
process.env.VITE_PWA_ENABLED === "true" &&
process.env.NODE_ENV === "production"
) {
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 - not enabled or not in production",
);
}