3
votes

Building the first React app based on create-react-app. It already have a service-worker.js in production build, but I need to add couple JavaScript (workers) files manually. These files are not included in the HTML and service worker do not cache them.

What is the correct way to add files to service worker cache list?

1
yes, I am using the create-react-app - Serge

1 Answers

0
votes

Because I did not find better solution, I decided to modify the file node_modules/react-scripts/config/webpack.config.prod.js

Find line

new SWPrecacheWebpackPlugin({

and paste below

mergeStaticsConfig: true,
stripPrefix: './public/',
staticFileGlobs: ['./public/./js/jimp.min.js', './public/./js/jimp-worker.js'],