Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to access service worker file as /sw.js #291

Open
michaelu123 opened this issue Apr 14, 2022 · 3 comments
Open

Need to access service worker file as /sw.js #291

michaelu123 opened this issue Apr 14, 2022 · 3 comments

Comments

@michaelu123
Copy link

I want to install wegue as a Progressive Web App, mainly, so that it runs also in offline mode. I can put all the tiles into the static folder. But I do not know how to put the service worker js file sw.js into the root directory, besides index.html. When I try to access the URL with /sw.js, I get a 404 error. I can put it into the static dir, so I can access /static/sw.js, but then /index.html is not in the scope of the service worker, and /index.html is not cached by the service worker, so the app can not run in offline mode.
What I need is a Vue route to /sw.js, but I do not know how this can be done with Wegue, as I can not see any routing code anywhere.

@JakobMiksch
Copy link
Collaborator

Hi @michaelu123 recently I tested the PWA approach as well. See here. For the generation of the service worker I used the plugin workbox-webpack-plugin.
But in general, Vue.js provides out-of-the-box support for PWA using vue-cli. Unfortunately Wegue is not built with vue-cli (yet).

@michaelu123
Copy link
Author

In the meantime I used the "serviceworker-webpack-plugin", Version 0.2.3 with Vue Version 2.6.14 and vue-template-compiler 2.6.14. All to be found in https://github.com/michaelu123/wegue. It may interest you, that our goal is to have a PWA that can work entirely offline, including the map tiles. This works only if we restrict the area and the zoomlevels. The map covers only a town quarter in Munich (Pasing), and zoom levels 14-16. The tiles consume ca. 8-10 Mbytes. We put them into a zip file, and let the service worker during installation decompose the zip and put the tiles into the static cache. To be seen in src/sw.js.
In order to restrict area and zoom levels I had to change src/components/ol/Map.vue and src/factory/Layer.js, because I could not find any Wegue-hooks for these changes. The changes are marked with the comment // MUH.

@fschmenger
Copy link
Collaborator

Hi @michaelu123. Good to hear you got the service worker to work.
I think the constraints on the map's extent and zoom level could be quite useful as general configuration parameters. Extent is currently supported on a layer level only (zoom isn't supported at all yet). Feel free to open up an issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants