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

Provide function to filter what gets injected #192

Closed
Snugug opened this issue Dec 15, 2021 · 5 comments
Closed

Provide function to filter what gets injected #192

Snugug opened this issue Dec 15, 2021 · 5 comments

Comments

@Snugug
Copy link

Snugug commented Dec 15, 2021

The injectManifest functionality is great for building your own custom service worker, but it appears as if the only option I have when using it is inject every file that Vite generated, or use something else. Precaching (which is what this is usually used for) should IMO be used sparingly on key important assets, not on everything. As such, I'd love a config option to pass a function, that effectively acts as a filter on the array of items being sent to Workbox to inject. I'm also happy to contribute this functionality myself if you're up for that.

Thanks!

@userquin
Copy link
Member

userquin commented Dec 15, 2021

@Snugug why not just use the injectManifest plugin option? You can filter using the globPatterns and globIgnores options. See for example the sveltekit example https://github.com/antfu/vite-plugin-pwa/blob/main/examples/sveltekit-pwa/pwa-configuration.js#L50

@Snugug
Copy link
Author

Snugug commented Dec 16, 2021

Thanks! I'll look at that tomorrow!

Maybe this winds up being a documentation issue instead of a feature request, as this config is buried under static asset handling instead of configuration of injectManifest where I expected it to be.

@userquin
Copy link
Member

@Snugug check also some hints I add on your issue 151 on chromeos

@userquin
Copy link
Member

@Snugug about the docs, just read https://vite-plugin-pwa.netlify.app/workbox/#how-is-workbox-build-related-to-vite-plugin-pwa

You can see the options provided to workbox here https://vite-plugin-pwa.netlify.app/workbox/#how-is-workbox-build-related-to-vite-plugin-pwa and here https://github.com/antfu/vite-plugin-pwa/blob/main/src/types.ts#L87 (both options are workbox types):

@userquin
Copy link
Member

userquin commented Jan 12, 2022

closing this since we have also included the sw for development on release version 0.11.13

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

No branches or pull requests

2 participants