Skip to content

Commit

Permalink
fix(dev): 404 workbox-*.js when base option exists (#389)
Browse files Browse the repository at this point in the history
* fix(dev): 404 workbox-*.js when base option exists

* chore: test fro slash and remove semicolon

Co-authored-by: hexuan <hexuan@idea.edu.cn>
Co-authored-by: Joaquín Sánchez <userquin@gmail.com>
  • Loading branch information
3 people committed Oct 9, 2022
1 parent ce948b5 commit 3b6809e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/dev.ts
Expand Up @@ -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')
}
},
}
Expand Down

0 comments on commit 3b6809e

Please sign in to comment.