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

New Vite Service Worker Plugin #151

Closed
1 of 5 tasks
Snugug opened this issue Dec 1, 2021 · 10 comments
Closed
1 of 5 tasks

New Vite Service Worker Plugin #151

Snugug opened this issue Dec 1, 2021 · 10 comments
Assignees
Labels
experience: dx Improvements to developer experience request: feature New feature or request scope: general Pertains to the codebase in general

Comments

@Snugug
Copy link
Collaborator

Snugug commented Dec 1, 2021

Current SW compilation from Vite Plugin PWA doesn’t meet the following core needs:

  • Manipulation (filtering, additions, etc…) of files for Workbox’s InjectManifest precache (so we don’t have to precache every single generated Vite file)
  • Not requiring Workbox Window to register a Service Worker
  • Not requiring InjectManifest to compile service worker (for Workbox Recipes compatibility)
  • Option for chunkFileNames to not include a hash
  • Ability to test Service Workers during development (optional)
@Snugug Snugug added request: feature New feature or request experience: dx Improvements to developer experience scope: general Pertains to the codebase in general labels Dec 1, 2021
@Snugug
Copy link
Collaborator Author

Snugug commented Dec 15, 2021

May icebox this if vite-pwa/vite-plugin-pwa#192 lands

@userquin
Copy link

@Snugug I'm also interested on trying to fix this list, we can fix it, PR are welcome on the plugin, some hints:

  1. you can use globPatterns and globIgnores
  2. I need to review the plugin, but I think you don't need to use the virtual module virtual:pwa-register (using workbox-window)
  3. uhmm, maybe we can add another strategy for it, since the service worker is compiled, we only need to omit the injectManifest part
  4. I think this option should be done via vite configuration
  5. I have some branch on my fork with some tests to allow test on development.

@userquin
Copy link

@Snugug the repo and branch for sw on development can be found here https://github.com/userquin/vite-plugin-pwa/tree/feat/add-development-support

Just check the last plugin on src/index.ts module and the logic on src/dev.ts module.

@userquin
Copy link

@Snugug you can use injectRegister: null for entry 2, see description here: https://github.com/antfu/vite-plugin-pwa/blob/main/src/types.ts#L47

@userquin
Copy link

for 1) you can also use transformManifest

@userquin
Copy link

userquin commented Dec 16, 2021

FYI: working on a new strategy to compile custom sw

@Snugug
Copy link
Collaborator Author

Snugug commented Jan 5, 2022

Thanks to the above comments, and a rethink of how we may implement our SW, I think our implementation can move from creating a new SW plugin to improving how we use Vite PWA today. There are still some areas (like local development) where there is work needed, but we can survive without it right now.

@userquin
Copy link

@Snugug just check this jeffposnick/yt-playlist-notifier#2, using custom sw on development

@userquin
Copy link

userquin commented Jan 12, 2022

@Snugug pwa plugin released 0.11.13 with development support

@Snugug Snugug closed this as completed Jan 13, 2022
@userquin
Copy link

userquin commented Jan 13, 2022

@Snugug do you need to build only the service worker without injectManifest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experience: dx Improvements to developer experience request: feature New feature or request scope: general Pertains to the codebase in general
Projects
None yet
Development

No branches or pull requests

2 participants