service-worker
About service worker.
usage:
- place
./src/sw.js
in your project src dir
# refrer this code:
https://github.com/afeiship/configuration-files/blob/master/service-worker/sw.js
- Add this code to you app.js
import runtime from 'serviceworker-webpack-plugin/lib/runtime';
// ...
componentDidMount() {
//...
this.registerSw();
}
registerSw() {
if ('serviceWorker' in navigator) {
runtime.register();
}
}
// ...
- use app-kits
plugins:[
//...
plugins.serviceWorker()
]
resources:
- https://github.com/oliviertassinari/serviceworker-webpack-plugin
← semver single-html →