Skip to content

Commit 1c829d0

Browse files
sprabowopi0
authored andcommitted
fix: routing order for default offline route (/.*). it must be last order (#100)
1 parent 854d826 commit 1c829d0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/workbox/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ function getOptions (moduleOptions) {
112112
delete options.offlinePageAssets
113113
}
114114

115-
// Optionally cache other routes for offline
116-
if (options.offline && !options.offlinePage) {
117-
options._runtimeCaching.push({
118-
urlPattern: fixUrl(`${routerBase}/.*`),
119-
handler: 'networkFirst'
120-
})
121-
}
122-
123115
if (options.cachingExtensions) {
124116
options.cachingExtensions = loadScriptExtension.call(this, options.cachingExtensions)
125117
}
@@ -136,6 +128,15 @@ function getOptions (moduleOptions) {
136128
// =============================================
137129

138130
function addTemplates (options) {
131+
// Optionally cache other routes for offline
132+
const routerBase = this.options.router.base
133+
if (options.offline && !options.offlinePage) {
134+
options.runtimeCaching.push({
135+
urlPattern: fixUrl(`${routerBase}/.*`),
136+
handler: 'networkFirst'
137+
})
138+
}
139+
139140
// Add sw.template.js
140141
this.addTemplate({
141142
src: path.resolve(__dirname, 'templates/sw.template.js'),

0 commit comments

Comments
 (0)