create-react-scripts-workbox
v0.1.4
Published
Enable workbox-webpack-plugin to create-react-scripts
Downloads
4
Readme
create-react-scripts-workbox
Repalce old sw-precache-webpack-plugin Plugin to workbox-webpack-plugin.
It also allow you to add serviceWorker.js
to extend the service-worker.js
generated in webpack build.
Like what importScripts
did in sw-precache-webpack-plugin
.
Example Usage:
Modify crs.config
Modify crs.config
as below.
const { compose } = require('create-react-scripts')
module.exports = compose(
require('create-react-scripts-workbox')(/* options passed to sass-loader*/),
...
);
Customize service-worker (Optional)
Please make sure you read the follwing issues. (https://github.com/GoogleChrome/workbox/issues/672) (https://github.com/GoogleChrome/workbox/issues/795)
Create serviceWorker.js
under your application folder
importScripts('https://unpkg.com/[email protected]');
const workboxSW = new WorkboxSW({clientsClaim: true});
// This array will be populated by workboxBuild.injectManifest() when the
// production service worker is generated.
workboxSW.precache([]);
workboxSW.router.setDefaultHandler({
handler: workboxSW.strategies.staleWhileRevalidate()
});