Where I work we create applications supporting development, education, and healthcare development efforts in South East Asian countries. As such, we usually design applications suited for the very poor network connectivity that's the only one available in many areas in the region.
We develop offline capable or offline first applications every time we can and we'd like to be able to have access to Metabase dashboards in this kind of scenarios.
As such I'm trying to add a service worker to cache the /embed/ application entry point and I have a working proof of concept that caches assets under
/app/dist/ so they can be served even when offline (and without attempting a very slow round trip to a server thousands of kilometers and several high latency hops away).
However I've never used Clojure/Ring before so there are some things I'd like to get working in the "proper" way before eventually submitting a PR (assuming you're interested in including this kind of functionality in Metabase).
I need to find how the integration between Clojure/Ring and Webpack works, namely: how do you serve dev assets when in dev and production assets when in production (as in, served from the uberjar?).
I've found the
config/is-dev function but then I never found it used in the routes.clj to serve a different asset depending on its value (reminder that the service worker has to be served from
What I'd like to achieve is to serve a
/service-worker.js when in production mode and serve the service worker from webpack-dev-server when in dev mode. How do I get the exact URL of the service worker (something like
http://local-ip:8080/sw.hot.bundle.js?628f44a478c3a78d070f ) in Clojure code so I can create a route for it? Are there other approaches to serve that file that I'm missing?
Thanks in advance!