From 1c829d01d23ca4fd40a23eecbfc24ce6be48e48d Mon Sep 17 00:00:00 2001 From: Sigit Prabowo Date: Thu, 13 Dec 2018 04:11:02 +0700 Subject: [PATCH] fix: routing order for default offline route (/.*). it must be last order (#100) --- packages/workbox/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/workbox/index.js b/packages/workbox/index.js index 7d8b0b47..3d4a7604 100755 --- a/packages/workbox/index.js +++ b/packages/workbox/index.js @@ -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) } @@ -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'),