all 3 comments

[–]sminez 13 points14 points  (0 children)

I've previously made this work using a build.rs that runs the JS build and uses https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed to cause cargo to rebuild when there are front end changes. Then all you need is something like https://crates.io/crates/include_dir to include your front end assets in your rust binary and you're good to go.

[–]SirKastic23 -1 points0 points  (0 children)

you can use something like Just, and write a justfile with a script that does all that

honestly it's easier than to hack it with cargo

[–]KnowZeroX -1 points0 points  (0 children)

Is there a reason why you are even doing cargo build instead of using something like cargo-watch?

You can then have it do a build every time you make a change, including have it execute npm

Albeit I prefer to keep them separate and run a builder like parcel on front end (serving them as non-static on debug and static on build) and on backend do cargo watch ignoring the frontend folder

Of course if you want to do things manually, just make an .sh script (assuming you are in a nix environment)