When I publish angular pwa application to subfolder in IIS, pwa application not work in offline.
ng build --prod --baseHref=/subfolder/ does not help.
I use htt
The --baseHref=/mypath/ for building from Vinod led me the way, thanks!! Some more observations:
Angular's service-worker seems to be case sensitive on URLs: If in your ngsw.json you have /MyPath/index.html and someone runs the page typing mysite.com/mypath the service worker fails. Nasty! As per the spec the path of a URL is case-sensitive, but well...
If you use IIS: Just stopping a website will NOT simulate an offline situation for the Angular service-worker. You would have to stop the entire IIS.
From my observation the manifest does not matter for the service worker / offline functionality. You can comment it out in index.html. Required for install only. Vinod's values worked for that.
Useful steps for newbies to follow what's going on:
After a build check ngsw.json in dist. All files should be prefixed with /mypath/.
After loading in Chrome check DevTools/Application/Cache storage. The entry "ngsw:/...:assets:app:cache" should contain the files from ngsw.json WITH /mypath/ prefix.
Have DevTool/Network open when hitting F5 too see WHERE files come from. For files to work offline a refresh should show (ServiceWorker) in the size column.
I found that putting baseHref in angular.json also works in this situation. Makes sense next to outputPath.
"outputPath": "D:/somewhere/WwwRoot/full/public/path",
"baseHref":"/full/public/path/",