Hi Michal, thanks for this!
Quick question: Why do you still register the firebase-messaging-sw.js ?
shouldn't you use the CRA serviceworker.register() function to register the CRA sw, which is now appended with the firebase sw?
Hi! That's a great question that. I should explain that better.
It's because cra-append-sw on npm start is ran in a dev mode meaning that as per their documentation:
dev creates public/<file> instead of appending the code to build/service-worker.js
So if you want it running in development you need to register it. I actually modified the if statement later on and didn't update it in the post. Now it looks like this:
if ('serviceWorker' in navigator && process.env.NODE_ENV !== 'production')
Hi Michal, thanks for this!
Quick question: Why do you still register the firebase-messaging-sw.js ?
shouldn't you use the CRA
serviceworker.register()
function to register the CRA sw, which is now appended with the firebase sw?Hi! That's a great question that. I should explain that better.
It's because cra-append-sw on
npm start
is ran in a dev mode meaning that as per their documentation:So if you want it running in development you need to register it. I actually modified the if statement later on and didn't update it in the post. Now it looks like this:
awesome! thanks for this clarification
@sjbuysse apparently we missed that there is a simpler way now for. CRA 4.0.0 has the service worker file available for extension: dev.to/m3h0w/don-t-struggle-with-e...