fd-vue-webapp icon indicating copy to clipboard operation
fd-vue-webapp copied to clipboard

Service worker introduction

Open ubaldop opened this issue 5 years ago • 5 comments

As suggested by @rafmjr in #167 it would be useful to add a Service Worker to make the application a PWA.

ubaldop avatar Oct 03 '18 09:10 ubaldop

We are using vue-onsenui for mobile and it supports PWA as reported here.

mcicolella avatar Oct 03 '18 14:10 mcicolella

I'm planning to do an implementation of these three:

https://onsen.io/v2/guide/pwa/tutorial.html#service-worker https://developers.google.com/web/fundamentals/primers/service-workers/ https://developers.google.com/web/fundamentals/app-install-banners/

I would need to see which resources to cache on installation of the SW though.

rafmjr avatar Oct 07 '18 00:10 rafmjr

I'm having troubles including with the webpack configuration. If I require the SW from src/main.js, the service worker is handled by webpack and its name is hashed. When registering the SW you need to specify the path of the file, but since this is generated, I can't provide the right path.

I tried including as static resource directly in index.html but then the file file is placed at /static/sw.js. This doesn't work, since the SW needs to be scoped at the very root so it can handle all the requests coming from /index.html

My knowledge of webpack is very basic, so I would appreciate any advice given. If not, is there any way I can place the at the same level of index.html?

Thank you very much for you help in advance.

rafmjr avatar Oct 08 '18 02:10 rafmjr

Hi rafmjr, Take a look here. https://14islands.com/blog/2017/01/19/progressive-web-app-from-scratch/ Into "Caching strategy" where speaks about addressing a dynamic HTML page which changes address every time it runs

amenak77 avatar Oct 08 '18 06:10 amenak77

@rafmjr any news about the service worker?

amenak77 avatar Oct 18 '18 13:10 amenak77