Per default there is a service worker script in a freshcreate-react-app
project included. I dont need that default registerServiceWorker.js
and the default service-worker.js
(hidden and available in build) because I want to add my own Service Worker. I would like to create my own service worker code with es6 syntax also, so just adding a 'sw.js' into the public folder and register it in my index.html is not the best option for me. How can I build some custom sw-code with ES6
create-react-app
?
If you would prefer disable the built in service-worker prior to your initial production deployment, then remove the call to serviceWorkerRegistration.register()
from src/index.js
and add your own service worker.
If your site/app has already been in production then swap it out for serviceWorkerRegistration.unregister().
After the user visits your page that has serviceWorkerRegistration.unregister()
, the service worker will be uninstalled and it might take up to 24 hours for the cache to be invalidated (depending on how the service worker is served)
The other option would be to eject and configure their built in solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With