cargo-web icon indicating copy to clipboard operation
cargo-web copied to clipboard

Add in --watch option

Open Pauan opened this issue 7 years ago • 3 comments

Right now if you use cargo web start it will automatically re-build if the files change, which is great!

But I'm developing a Chrome Extension, so cargo web start doesn't work for me (because the compiled files are loaded into the browser, not displayed on an HTML page).

So it would be great if I could do cargo web build --watch, cargo web deploy --watch, and cargo web test --watch

When using the --watch option it will watch for file changes (just like cargo web start) and will then re-run cargo web build (or cargo web deploy / cargo web test) automatically.

Pauan avatar Feb 01 '18 17:02 Pauan

Yep. This is something I was planning on adding myself anyway. (:

Right now I'm switching gears a little to stdweb so it will take some time until I can take a stab at this. That said, if you'd like to have this sooner than later you could probably do it yourself without much trouble. Very roughly - move most of the cmd_deploy.rs to a separate function, run it, if the first built succeeds start a loop, instantiate a watcher from the notify crate (see how it's done in cmd_start; here it's simpler since it can just run on the main thread), pass it whatever project.paths_to_watch() returns, wait for changes from the watcher, rebuild and redeploy, loop again.

koute avatar Feb 01 '18 17:02 koute

@koute Thanks for the tips! I would love to implement this myself, but my harddrive recently got corrupted and I'm still recovering from that. Within a couple days I should have recovered, and then I can take a stab at that.

Pauan avatar Feb 01 '18 17:02 Pauan

Right now you can use the regular cargo-watch like this:

cargo watch -x "web build"

byw avatar Apr 15 '18 22:04 byw