A
A
Andrey Novikov2020-12-25 17:05:26
React
Andrey Novikov, 2020-12-25 17:05:26

Why doesn't react-scripts build add service-worker.js to the build?

Before that, I apparently used the older create-react-app, where build was created along with service-worker.js. Now I have registered serviceWorker.register() in index.js, but it is not in the build. If you transfer service-worker.js from builds of other applications to mine, then it starts to swear at the lack of precache-manifest.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Novikov, 2020-12-25
@Andreeyyy

Created another app with cra-template-pwa template. Further from it I transferred the serviceWorkerRegistration.js and service-worker.js files to my project. Added the serviceWorkerRegistration.register() line to index.js instead of serviceWorker.register(). Now it's working!

T
twolegs, 2020-12-25
@twolegs

https://create-react-app.dev/docs/making-a-progres...
You need to add the src/service-worker.js file
Or use the cra-template-pwa template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question