-
Notifications
You must be signed in to change notification settings - Fork 832
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
When auto-generating SW with workbox-webpack-plugin there is no way to keep custom SW code? #970
Comments
Seems like others have stumbled here too: nuxt-community/pwa-template#5 |
Hello @johnnyreilly—Apologies, as this is an area that should be clearer in the v3 docs. Translating the v2 docs from JSDoc to HTML lost a lot of the examples. You should be able to use the Webpack plugin in "inject manifest" mode, where you pass in your custom service worker code in as a the E.g. new WorkboxBuildWebpackPlugin({
globPatterns: ['**\/*.{html,js,css}'],
swSrc: './src/sw.js',
swDest: './build/sw.js',
}); and inside of const workboxSW = new WorkboxSW();
// The [] will be replaced:
workboxSW.precache([]);
// Custom code... |
Thanks that's brilliant - glad it's possible! The more I learn about workbox, the more I like it! I've put my money where my mouth is with my latest blog post too 😉 https://blog.johnnyreilly.com/2017/11/the-typescript-webpack-pwa.html I look forward to seeing the V3 release. I'd say that the only criticism I have of workbox is the documentation. And that's been visibly improving over the last couple of weeks so good work! Looking forward to even more goodness! |
Library Affected:
workbox-webpack-plugin
Browser & Platform:
"webpack*
Issue or Feature Request Description:
Hello! I've been trying workbox out over the last week and it's great! I'm using the
workbox-webpack-plugin
to generate my service worker. Now I've gone beyond naive scenarios I'd like to try generating a SW and including some custom code as well. Alas, there doesn't seem to be a way to generate a SW that includes custom code.This is my config: https://github.com/johnnyreilly/reactspike/blob/master/webpack.config.production.js#L52
What I want to do is include this custom code in my SW:
From what I can tell there doesn't appear to be a way to plug custom SW code into the webpack build pipeline. Or have I missed something?
All help appreciated. Much ❤️ 🌻
The text was updated successfully, but these errors were encountered: