From 3b6809e1786bee5b6bdfb892dcba98c1d148d9cb Mon Sep 17 00:00:00 2001 From: Mox Date: Mon, 10 Oct 2022 04:18:45 +0800 Subject: [PATCH] fix(dev): 404 workbox-*.js when base option exists (#389) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(dev): 404 workbox-*.js when base option exists * chore: test fro slash and remove semicolon Co-authored-by: hexuan Co-authored-by: Joaquín Sánchez --- src/plugins/dev.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/dev.ts b/src/plugins/dev.ts index 7d532430..bbd6864d 100644 --- a/src/plugins/dev.ts +++ b/src/plugins/dev.ts @@ -155,9 +155,11 @@ export function DevPlugin(ctx: PWAPluginContext): Plugin { } return await fs.readFile(swDest, 'utf-8') } + + const key = normalizePath(`${options.base}${id.startsWith('/') ? id.slice(1) : id}`) - if (swDevOptions.workboxPaths.has(id)) - return await fs.readFile(swDevOptions.workboxPaths.get(id)!, 'utf-8') + if (swDevOptions.workboxPaths.has(key)) + return await fs.readFile(swDevOptions.workboxPaths.get(key)!, 'utf-8') } }, }