Skip to content

Commit

Permalink
fix: skip waiting check (#306)
Browse files Browse the repository at this point in the history
Co-authored-by: Joaquín Sánchez <[email protected]>
  • Loading branch information
mastercoms and userquin authored Jun 30, 2022
1 parent 7e81e59 commit d27a9a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ export function VitePWA(userOptions: Partial<VitePWAOptions> = {}): Plugin[] {
transformIndexHtml: {
enforce: 'post',
transform(html) {
return options.disable ? html : injectServiceWorker(html, options)
if (options.disable)
return html

// if virtual register is requested, do not inject.
if (options.injectRegister === 'auto')
options.injectRegister = useImportRegister ? null : 'script'

return injectServiceWorker(html, options)
},
},
generateBundle(_, bundle) {
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function resolveOptions(options: Partial<VitePWAOptions>, viteConfi
const { vitePlugins = defaultInjectManifestVitePlugins, ...userInjectManifest } = options.injectManifest || {}
const injectManifest = Object.assign({}, defaultInjectManifest, userInjectManifest)

if ((injectRegister === 'auto' || registerType == null) && registerType === 'autoUpdate') {
if ((injectRegister === 'auto' || injectRegister == null) && registerType === 'autoUpdate') {
workbox.skipWaiting = true
workbox.clientsClaim = true
}
Expand Down

0 comments on commit d27a9a1

Please sign in to comment.