You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to build a PWA with Leptos/cargo-leptos and it's slowly coming along (I'm quite a noob with Rust and Leptos) I got to the point where caching with Service Worker... works but I'm now having a series of problems with excessive caching.
Starting from the start-axum-workspace template I added the service worker with caching of the "usual" assets, mostly project-name.[css|js|wasm]... however that will then require me to delete all site data every time I change something and cargp leptos watch refreshes, because if not the service worker will happily serve the old version of everything from local, breaking rehydration big time.
I tried to use the hash-file option and it would work, but then I need to manually change the source of the service-worker.js file because it needs to list the assets for precaching.
A solution would be to run a script that checks the assets in target/site and adds them to the service worker file before this is copied to target/site (a similar approach is used in the assorted JS plugins to manage Google's WorkBox).
I didn't find any feature that would allow me to do that, since it would need to run within the cargo leptos watch loop, so I was wondering if there's something planned to address this kind of problem.
As explained running a script at the right phase (after WASM and bin builds are finished but before the assets are copied to site) would be the most flexible and probably also simplest solution to implement (and could even be used to call npx if that's needed to prepare other JS-side packages or libraries)
Thanks!
The text was updated successfully, but these errors were encountered:
Hello!
I'm currently trying to build a PWA with Leptos/cargo-leptos and it's slowly coming along (I'm quite a noob with Rust and Leptos) I got to the point where caching with Service Worker... works but I'm now having a series of problems with excessive caching.
Starting from the
start-axum-workspace
template I added the service worker with caching of the "usual" assets, mostlyproject-name.[css|js|wasm]
... however that will then require me to delete all site data every time I change something andcargp leptos watch
refreshes, because if not the service worker will happily serve the old version of everything from local, breaking rehydration big time.I tried to use the
hash-file
option and it would work, but then I need to manually change the source of theservice-worker.js
file because it needs to list the assets for precaching.A solution would be to run a script that checks the assets in
target/site
and adds them to the service worker file before this is copied totarget/site
(a similar approach is used in the assorted JS plugins to manage Google's WorkBox).I didn't find any feature that would allow me to do that, since it would need to run within the
cargo leptos watch
loop, so I was wondering if there's something planned to address this kind of problem.As explained running a script at the right phase (after WASM and bin builds are finished but before the assets are copied to
site
) would be the most flexible and probably also simplest solution to implement (and could even be used to callnpx
if that's needed to prepare other JS-side packages or libraries)Thanks!
The text was updated successfully, but these errors were encountered: