I'm making PWA with Angular and Firebase. Using StackBlitz for developing.
I want to make "Add to home screen" Chrome standard advice working when user opens my app in browser, but I can't correctly call "service worker" JS from my code...
I created sw.js in /src folder of my project. I've added it to 'scripts' and 'assets' sections in .angular-cli.json and .angular.json. And in StackBlitz everything works fine!
But when I deploy project to Firebase (using Stackblitz build-in functionality) nothing works... Seems like server doesn't see the file in expected dir (/src/sw.js)... Did anybody face same problem?
I don't think there's a way to fix it, I'm pretty sure the problem is the stackblitz server. but luckily firebase engineers made a simple node script to replace a single file. It worked for me. As the link describes just install git, and node, and then in command prompt run these commands: git
additional info:
I tried replicating your problem, let me know if the link works. https://stackblitz.com/edit/angular-epvm8w. Basically just in index.html. the js file just has alert("alert"); in it. it works like you said but when deployed i think the stackblitz server is replacing the content with html. I think this because in chrome developers panel under sources the js file had the same html as the index template from stackblitz's github. Makes me think it's just a bug. same thing happened to a css file.