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

Feature request: ability to run a script/exe before copying assets #363

Open
RobertoMaurizzi opened this issue Sep 21, 2024 · 0 comments
Open

Comments

@RobertoMaurizzi
Copy link

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, 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!

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

1 participant