-
Notifications
You must be signed in to change notification settings - Fork 29
Add service worker support #101
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
Conversation
Allow service worker options to be specified in the dojorc. If the file path for an existing service worker is provided, it is copied to the output directory. Otherwise, a service worker file is generated that contains a precache manifest, as well as any specified route handlers. Further, when generating a service worker from the rc, an additional entry point is added to the build that initializes the service worker at startup. Finally, iOS-specific meta tags related to PWAs are added to the application's index.html (requires an upgraded to html-webpack-plugin).
- Update README - Add missing util tests, as well as a functional test for the PWA meta tags - Fix: use `cachePrefix` from dojorc over package.json `name`
Codecov Report
@@ Coverage Diff @@
## master #101 +/- ##
=========================================
- Coverage 63.43% 60.83% -2.6%
=========================================
Files 8 8
Lines 361 383 +22
Branches 67 79 +12
=========================================
+ Hits 229 233 +4
- Misses 127 145 +18
Partials 5 5
Continue to review full report at Codecov.
|
src/sw-entry.ts
Outdated
| @@ -0,0 +1,5 @@ | |||
| if ('serviceWorker' in navigator) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file needed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not; it's in @dojo/webpack-contrib now. Good catch!
Resolves most of #96 (adding the
apple-touch-iconmeta tag requires additional voodoo that may be better suited forwebpack-contrib). Adds service worker support when usingdistanddevmodes. Relying on@dojo/webpack-contrib's service worker plugin, application developers can generate a fully-featured service worker via the.dojorcthat supports pre-caching and custom route handling (and is automatically initialized when the app starts), or they can provide the path of an existing service worker file that will be copied to the output directory.Tested locally on both Windows and macOS with a sandbox application, and verified on Windows with
dojo eject.