(not-very) minimal example using SWPrecacheWebpackPlugin
in a react / redux project.
Install npm packages
$ npm install
Start the server
$ npm start
The service worker is registered in the register-service-worker.ejs
template
The SWPrecacheWebpackPlugin
is in the plugins of the webpack.config.js
file
Although this example only has one webpack.config.js
file, I highly suggest you separate your production and local configurations into separate files that import common configurations from a single base config file. You will only need SWPrecacheWebpackPlugin
in production and it will get annoying to have all this caching while trying to develop. Here's an example of the local / production separation.