INSAgenda / yew-template

A crate to separate your HTML from your Rust code when using Yew
https://crates.io/crates/yew-template
MIT License
39 stars 3 forks source link

Trunk serve doesn't update template changes #30

Open Hessesian opened 1 year ago

Hessesian commented 1 year ago

If I modify css/elements in template, the generated template is not reloaded with trunk serve watcher. Fix is to call cargo clean and then trunk serve to see changes. If you would point me into work that has to be done I could try to fix it, thanks

MarcAntoine-Arnaud commented 1 year ago

Hello, You can use the trunk option (trunk watch -w folder) as mentioned in the documentation (trunk watch --help):

    -w, --watch <path>               Watch specific file(s) or folder(s) [default: build target parent folder]
Hessesian commented 1 year ago

Hi, I did try that (for example trunk serve -w src/templates/MainScreen.html ) but after changing text it still doesn't reload the website, furthermore not even when I cancel trunk serve and start it again, it needs that cargo clean command, which leads me to believe of some mysterious cache somewhere ?

nanobot248 commented 4 months ago

I just encountered the same problem. I think this is related to the fact that the rust file you are unsing the template_html! macro in doesn't change. And rustc has no way of knowing that the HTML file is part of the Rust source code and therefore the source file that uses template_html!(...) is considered unchanged. There is a pre-RFC for that topic: https://internals.rust-lang.org/t/pre-rfc-add-a-builtin-macro-to-indicate-build-dependency-to-file/9242

A workaround would be to use include_str! or include_bytes!, but then the generated binary would contain unused data.

I guess you could also work around it via a build.rs file, but i haven't really thought that through yet.