Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

publish - Angular PWA in IIS subfolder not work offline

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 https on web site.

How exactly reconfigure angular pwa application to work offline if application is not published to root of IIS but to subfolder of IIS?

Does anybody have functional demo of angular pwa application working offline after publishing to IIS subfolder?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I know I am very late on this, I have also struggled on this and finally followed these steps to solve the issue:

  1. In manifest.JSON file, set "scope": "." and "start_url": "./". This indicate that you are using sub-directory.

  2. Then build the project using CLI command ng build --prod --baseHref=/Your_sub_directory_name/

  3. And finally paste the dist folder content to your pointed Your_sub_directory_name IIS location.

  4. Then just refresh page and wait to register the service worker, you can check this in application tab of chrome's developer tool. Once service worker is reigstered, just switch to offline mode and you'll the page will work fine in offline.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...