-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($plugin-pwa): work with register-service-worker 1.7.0 (close #2222)…
… (#2229)
- Loading branch information
Showing
3 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/* global SW_BASE_URL, SW_ENABLED, GA_ID, ga, SW_UPDATE_POPUP, SW_POPUP_COMPONENT */ | ||
|
||
import Vue from 'vue' | ||
import { register } from 'register-service-worker' | ||
import SWUpdateEvent from './SWUpdateEvent' | ||
import event from './event' | ||
|
||
|
@@ -10,12 +9,13 @@ if (SW_UPDATE_POPUP && SW_POPUP_COMPONENT === 'SWUpdatePopup') { | |
Vue.component('SWUpdatePopup', () => import('./SWUpdatePopup.vue')) | ||
} | ||
|
||
export default ({ router, isServer }) => { | ||
// Register service worker | ||
router.onReady(() => { | ||
if (process.env.NODE_ENV === 'production' | ||
&& !isServer | ||
&& SW_ENABLED) { | ||
export default async ({ router, isServer }) => { | ||
if (process.env.NODE_ENV === 'production' && !isServer && SW_ENABLED) { | ||
// [email protected] references `window` in outer scope, so we have to import it dynamically in client | ||
const { register } = await import('register-service-worker') | ||
|
||
// Register service worker | ||
router.onReady(() => { | ||
register(`${SW_BASE_URL}service-worker.js`, { | ||
registrationOptions: {}, | ||
ready () { | ||
|
@@ -49,6 +49,6 @@ export default ({ router, isServer }) => { | |
} | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters