Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix($plugin-pwa): set current registration scope for service worker (Close: #1271) #1302

Merged
merged 1 commit into from
Feb 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@vuepress/plugin-pwa/lib/enhanceAppFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default ({ router, isServer }) => {
&& !isServer
&& SW_ENABLED) {
register(`${SW_BASE_URL}service-worker.js`, {
registrationOptions: { scope: `./${SW_BASE_URL}` },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is correct, because SW_BASE_URL is an absolute path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an empty object for registrationOptions is good enough. The default value of scope option is the directory that service-worker.js file exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right 👍

ready () {
console.log('[vuepress:sw] Service worker is active.')
event.$emit('sw-ready')
Expand Down