mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-06 13:40:16 +08:00
chore: register service worker manually, also catch errors
This commit is contained in:
parent
c2f20290d7
commit
c6620aba74
2 changed files with 17 additions and 1 deletions
|
@ -52,5 +52,21 @@ $(async (): Promise<void> => {
|
|||
void registration.unregister();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if ("serviceWorker" in navigator) {
|
||||
window.addEventListener("load", () => {
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js", { scope: "/" })
|
||||
.then((registration) => {
|
||||
console.log(
|
||||
"ServiceWorker registration successful with scope: ",
|
||||
registration.scope
|
||||
);
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
console.error("ServiceWorker registration failed: ", error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -90,7 +90,7 @@ export default {
|
|||
ViteMinifyPlugin({}),
|
||||
VitePWA({
|
||||
// injectRegister: "networkfirst",
|
||||
injectRegister: "script-defer",
|
||||
injectRegister: null,
|
||||
registerType: "autoUpdate",
|
||||
manifest: {
|
||||
short_name: "Monkeytype",
|
||||
|
|
Loading…
Add table
Reference in a new issue