mirror of
https://github.com/danbulant/Mangades
synced 2026-06-20 23:01:28 +00:00
20 lines
700 B
Svelte
20 lines
700 B
Svelte
<script>
|
|
/**
|
|
* This file handles serviceworker registration
|
|
* To enable it, import it from another file, ie. src/pages/_layout.svelte
|
|
* ⚠ The imported component could get treeshaken if not used, eg. <SW />
|
|
* For configuring the serviceworker, refer to sw.js
|
|
*/
|
|
if ("serviceWorker" in navigator) {
|
|
import("workbox-window").then(async ({ Workbox }) => {
|
|
const wb = new Workbox("/serviceworker.js");
|
|
const registration = await wb.register();
|
|
|
|
// Reload the page if the PWA has been updated. Change strategy if needed.
|
|
wb.addEventListener("redundant", () => {
|
|
location.reload();
|
|
console.log("updated app");
|
|
});
|
|
});
|
|
}
|
|
</script>
|