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

feat(service-worker): inject SW registeration script to all pages #299

Merged
merged 11 commits into from
Jun 29, 2022

Conversation

farnabaz
Copy link
Contributor

πŸ”— Linked issue

resolves #88

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -55,6 +49,11 @@ export const serviceWorker = defineNitroPreset(() => {
preview: 'npx serve ./public'
},
hooks: {
'prerender:route' (route) {
// TODO: use baseURL from nitro options
const baseURL = '/'
Copy link
Contributor Author

@farnabaz farnabaz Jun 20, 2022

Choose a reason for hiding this comment

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

@pi0 @danielroe Is there any way to access nitro inside presets other than passing it to hook?

Copy link
Member

Choose a reason for hiding this comment

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

No. Presets are evaluated for constructing config. We might improve this by supporting lazy evaluated hooks but for now you can directly pass nireo as second argument πŸ‘πŸΌ

@pi0
Copy link
Member

pi0 commented Jun 23, 2022

Any updates on this?

@farnabaz
Copy link
Contributor Author

@pi0 I updated hook signature and passed nitro as second argument. I think it is ready for first step, unless you see any missing part. WDYT?

src/prerender.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title WIP fix(service-worker): inject SW registeration script to all pages fix(service-worker): inject SW registeration script to all pages Jun 24, 2022
@pi0 pi0 marked this pull request as ready for review June 24, 2022 08:29
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for working on this.

@pi0 pi0 changed the title fix(service-worker): inject SW registeration script to all pages feat(service-worker): inject SW registeration script to all pages Jun 29, 2022
@pi0 pi0 merged commit 486f236 into main Jun 29, 2022
@pi0 pi0 deleted the fix/prerender-hook branch June 29, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prerender: hooks
3 participants