react-redux-universal-hot-example icon indicating copy to clipboard operation
react-redux-universal-hot-example copied to clipboard

Explanation of serviceworker

Open arfianadam opened this issue 8 years ago • 1 comments

Can you explain how the serviceworker works and generated in this boilerplate? Thanks.

arfianadam avatar Jan 03 '17 04:01 arfianadam

I just did some digging into this and wanted to share in case it can save anyone some time.

The TLDR is that in webpack/prod.config.js the sw-precache-webpack-plugin is added, and that plugin generates static/dist/service-worker.js. It's purpose without modifying anything is just to precache your site's resources.

The recommended way to extend the generated service worker file is using the importScripts option but you can also modify the template file.

stevenaldinger avatar Nov 11 '18 08:11 stevenaldinger