Skip to content

Commit

Permalink
fix(dev): custom service worker with custom base not working (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Mar 19, 2024
1 parent e195fe2 commit d42184a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugins/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export function DevPlugin(ctx: PWAPluginContext) {

const { options } = ctx
if (!options.disable && options.devOptions.enabled && options.strategies === 'injectManifest' && !options.selfDestroying) {
const name = id.startsWith(options.base) ? id.slice(options.base.length) : id
let name = id.startsWith(options.base) ? id.slice(options.base.length) : id
// Vite will remove the base from the request, and so we need to remove the leading /: fixes issue #683
if (name.length && name[0] === '/')
name = name.slice(1)
// the sw must be registered with .js extension in the browser, here we detect that request:
// - the .js file and source with .ts, or
// - the .ts source file
Expand Down

0 comments on commit d42184a

Please sign in to comment.