I can answer about using at the same time:
1. Development: in the catalog src:
- I am creating an empty file with the name
service-worker.js. A real one will be created after the build process, but this file must exist (even empty) in order to avoid an error message while working with ng serve. - I create a file with a name
firebase-messaging-sw.jswhose contents are: (add https://before both www, stakoverflow limits me to the number of links!)
importScripts('www.gstatic.com/firebasejs/3.9.0/firebase-app.js');
importScripts('www.gstatic.com/firebasejs/3.9.0/firebase-messaging.js');
firebase.initializeApp({
'messagingSenderId': 'xxxxxxxxxxxx' // replace by yours!
});
const messaging = firebase.messaging(); global-sw.js. ,
index.html ( , ). global-sw.js:
importScripts('service-worker.js');
importScripts('firebase-messaging-sw.js');
2. .angular-cli.json: dist ( ), .angular-cli.json :
. angular-cli.json - extract
3. : ng build -prod, service-worker.js. .