![]() ![]()
If you can, give it a shot and see if it works for you? I'm trying to work on a pull request (# 1 above can definitely be fixed in the source, # 2 needs more investigation to avoid breaking anything) currently stymied by setting up a dev environment for the packageįinal note: you can see my app working offline in this repo (using the build script at this line), and you can see a clone of that repo from the time where I was having the issue (so it still fails offline) here My current workaround is running this build script, after ng build -prod and before http-server. ![]() #Eve ng loading as localhost code(source code links are in the SO answer I can duplicate them here as well) Of the 3 available "states" that the ngsw-worker.js can be in, in my experience, EXISTING_CLIENTS_ONLY seems to bet set incorrectly.When comparing requests to these resources, ngsw-worker.js is expecting relative URLs Hosted versions of an Angular app, where the -base-href flag is set from the CLI, list absolute URLs for their service worker resources. #Eve ng loading as localhost fullI won't go into full detail here I've given a long explanation on this SO answer. I've been able to figure out two issue spots, that when worked around in my app, allow it to work offline. I've skipped mentioning this step above because it happens regardless of the Angular version (at least on >= 5.1.0, haven't tested with older versions). ![]() The CLI version used (1.6.4) initializes the app with Angular 5.1.0, but I've also tested on 5.2.1. I only used http-server to reproduce it because I wanted to keep the reproduction process as fast as possible, without introducing server side rendering. So this is not a http-server "not being SPA friendly" issue. Initially I noticed this behavior on a Universal app, doing server side rendering (following the universal-starter repo). Now, if you start the server again, loading the app on the /about route works (even though http-server is not SPA friendly, it doesn't redirect all requests to index.html), but the service worker kicks in. (With Universal/SSR, it stops working right away, most of the time with the first refresh after stopping the server, no matter the route - and the issue is not the hash in the generated ngsw.json, because I regenerate that at the end of the build process). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |