Skip to content

Commit

Permalink
fix(serviceworker): Fix service worker not registering (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanziness authored Sep 17, 2022
1 parent b9ac592 commit 4fc8e4d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ if (!process.server) {
onMounted(() => {
if (typeof window !== 'undefined') {
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
const registerSw = () => {
console.debug(`Registering service worker at /${swPath}`)
navigator.serviceWorker.register(`/${swPath}`)
})
}
if (document.readyState === 'complete') {
registerSw()
} else {
window.addEventListener('load', registerSw)
}
}
}
})
Expand Down

0 comments on commit 4fc8e4d

Please sign in to comment.