Skip to content

Commit

Permalink
fix: routing order for default offline route (/.*). it must be last o…
Browse files Browse the repository at this point in the history
…rder (#100)
  • Loading branch information
sprabowo authored and pi0 committed Dec 12, 2018
1 parent 854d826 commit 1c829d0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/workbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ function getOptions (moduleOptions) {
delete options.offlinePageAssets
}

// Optionally cache other routes for offline
if (options.offline && !options.offlinePage) {
options._runtimeCaching.push({
urlPattern: fixUrl(`${routerBase}/.*`),
handler: 'networkFirst'
})
}

if (options.cachingExtensions) {
options.cachingExtensions = loadScriptExtension.call(this, options.cachingExtensions)
}
Expand All @@ -136,6 +128,15 @@ function getOptions (moduleOptions) {
// =============================================

function addTemplates (options) {
// Optionally cache other routes for offline
const routerBase = this.options.router.base
if (options.offline && !options.offlinePage) {
options.runtimeCaching.push({
urlPattern: fixUrl(`${routerBase}/.*`),
handler: 'networkFirst'
})
}

// Add sw.template.js
this.addTemplate({
src: path.resolve(__dirname, 'templates/sw.template.js'),
Expand Down

0 comments on commit 1c829d0

Please sign in to comment.