luminus-framework / luminus-template

a template project for the Luminus framework
http://www.luminusweb.net/
MIT License
647 stars 147 forks source link

Add template for PWA #454

Open D00mch opened 5 years ago

D00mch commented 5 years ago

It would be nice to have Progressive web app template.

yogthos commented 5 years ago

I'd be open to a PR for this. What would you have in mind specifically for making the progressive template?

D00mch commented 5 years ago

I want my web app to run on desktop and mobile devices like native app, offline, with notification support and possibility to distribute it as an anroid .apk. Which is supported by PWA.

To make web project a PWA, you basically need to set up servise worker to get it work offline and add a manifest with icons.

But the devil in the details.

I don't have any experience with js and little experience with cljs, it's a dark forest for me. When I tried to implement PWA with my pet project, I failed. ServiceWorker is saving cache, but the app is not working offline, probably because I haven't cached all the important stuff. I got stuck at this point (commit with worker).

I also implemented the same with clojurscript, but it had problems with servicWorker registration.

May be the PWA will also be a nice feature for you 3rd Web Development with Clojure book.

Ideally I would want to be able to do: lein new luminus <name> +cljs +reagent +pwa +...

yogthos commented 5 years ago

Ah I see, I don't have any experience with PWAs myself either unfortunately. It might be worth checking on Clojurians slack to see if anybody got this working already. And I'll take a look to see if it's something I can add to the book. A +pwa profile seems like a good idea if we get this figured out.

dijonkitchen commented 5 years ago

Maybe a CLJS wrapper around https://github.com/GoogleChrome/workbox ?

yogthos commented 5 years ago

Oh I haven't seen workbox before, looks like it would be a good fit.

D00mch commented 4 years ago

Good news! There is a library page-renderer that uses GoogleChrome/workbox inside. I was able to pass lighthouse audit (pwa test) which confirmed that my app is a PWA.

Here is the commit with the changes I made.

yogthos commented 4 years ago

Nice, that looks really straight forward. Might be best to just add it to the docs then as an example.

D00mch commented 4 years ago

Yes, I think docs would be enough. I also created an example project https://github.com/Liverm0r/PWA-clojure