Skip to content

Commit

Permalink
fix: dev plugin and base url (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Jun 1, 2023
1 parent 2930a3c commit 2920e75
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/dev.ts
Expand Up @@ -156,10 +156,12 @@ export function DevPlugin(ctx: PWAPluginContext) {
return await fs.readFile(swDest, 'utf-8')
}

const key = normalizePath(`${options.base}${id.startsWith('/') ? id.slice(1) : id}`)

if (swDevOptions.workboxPaths.has(key))
return await fs.readFile(swDevOptions.workboxPaths.get(key)!, 'utf-8')
// check the entry only if the request starts with the base, otherwise ignore the request
if (id.startsWith(options.base)) {
const key = normalizePath(id)
if (swDevOptions.workboxPaths.has(key))
return await fs.readFile(swDevOptions.workboxPaths.get(key)!, 'utf-8')
}
}
},
}
Expand Down

0 comments on commit 2920e75

Please sign in to comment.