-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workbox): workbox-window support
- Loading branch information
pooya parsa
committed
Mar 5, 2019
1 parent
4e9aee5
commit 2e356d0
Showing
4 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register('<%= options.swURL %>', { | ||
import { Workbox } from 'workbox-window/build/workbox-window.<%= options.dev ? 'dev' : 'prod' %>.mjs' | ||
|
||
export default async function(ctx, inject) { | ||
const workbox = new Workbox('<%= options.swURL %>', { | ||
scope: '<%= options.swScope %>' | ||
}).then(function(registration) { | ||
window.$sw = registration | ||
}).catch(function(error) { | ||
console.error('Service worker registration failed:', error) | ||
}) | ||
|
||
// Inject as $workbox | ||
inject('workbox', workbox) | ||
|
||
if (!'serviceWorker' in navigator) { | ||
workbox._unsupported = true | ||
return // Unsupported browser! | ||
} | ||
|
||
workbox.register() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11271,6 +11271,18 @@ wordwrap@~1.0.0: | |
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" | ||
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= | ||
|
||
workbox-core@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/workbox-core/-/workbox-core-4.0.0.tgz#3b4aa11c9d739361ed8916b7611abc3b6fefed8b" | ||
integrity sha512-FRoOUuJBl7COTwvGO5FC9k0VyYGv/LkjVqgVwKk9MXQn/Xi+bvGDcqSVF7qfT+sJ6Ffcr/V+dVMpoZAE/X5e+g== | ||
|
||
[email protected]: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/workbox-window/-/workbox-window-4.0.0.tgz#a4d6404c96cc65d4882f79331d4e812c10f912a6" | ||
integrity sha512-gdLzP/L0vu5Gi3pdUYtVNmg0yE7OriEuYZBoLt8AYoILXh6cta9WsWHKQ0/pXfmEmZywr4Dfu0qkLLvc9VlZGQ== | ||
dependencies: | ||
workbox-core "^4.0.0" | ||
|
||
worker-farm@^1.5.2: | ||
version "1.6.0" | ||
resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.6.0.tgz#aecc405976fab5a95526180846f0dba288f3a4a0" | ||
|