Permalink
Browse files

feat(workbox): expose registration as window.$sw

Also better error handeling when registration failed
  • Loading branch information...
pi0 committed Nov 16, 2017
1 parent 6679d73 commit a5ddf5992c61ee759a292d1af95a2cf0daac9d73
Showing with 6 additions and 2 deletions.
  1. +6 −2 packages/workbox/templates/sw.plugin.js
@@ -1,10 +1,14 @@
window.onNuxtReady(() => {
if (!('serviceWorker' in navigator)) {
console.warn('serviceWorker is not supported')
console.warn('Service workers are not supported.')
return
}
navigator.serviceWorker.register('<%= options.swURL %>', {
scope: '<%= options.swScope %>'
})
}).then(function(registration) {
window.$sw = registration
}).catch(function(error) {
console.error('Service worker registration failed:', error);
});
})

0 comments on commit a5ddf59

Please sign in to comment.