Permalink
Browse files

feat(worbox): add offline option for making it optional (#59)

Make all-inclusive NetworkFirst route registration optional.

Fixes #24.
  • Loading branch information...
gerardo-rodriguez authored and pi0 committed Apr 2, 2018
1 parent 0c99ab9 commit 76de33cc4f7dde9e1b930be773add3736851a95e
Showing with 9 additions and 5 deletions.
  1. +9 −5 packages/workbox/index.js
@@ -57,24 +57,28 @@ function getOptions (moduleOptions) {
modifyUrlPrefix: {
'': fixUrl(publicPath)
},
offline: true,
_runtimeCaching: [
// Cache all _nuxt resources at runtime
// They are hashed by webpack so are safe to loaded by cacheFirst handler
{
urlPattern: fixUrl(publicPath + '/.*'),
handler: 'cacheFirst'
},
// Cache other routes if offline
{
urlPattern: fixUrl(routerBase + '/.*'),
handler: 'networkFirst'
}
],
runtimeCaching: []
}
const options = defaultsDeep({}, this.options.workbox, moduleOptions, defaults)
// Optionally cache other routes for offline
if (options.offline) {
defaults._runtimeCaching.push({
urlPattern: fixUrl(routerBase + '/.*'),
handler: 'networkFirst'
})
}
return options
}

0 comments on commit 76de33c

Please sign in to comment.