add watch script

This commit is contained in:
Felix Ableitner 2024-01-30 11:09:18 +01:00
parent 885555ad09
commit 334a923d79
2 changed files with 15 additions and 6 deletions

View File

@ -11,16 +11,14 @@ The Ibis is a [bird which is related to the Egyptian god of knowledge and scienc
You need to install [cargo](https://rustup.rs/) and [trunk](https://trunkrs.dev). Then run the following commands in separate terminals: You need to install [cargo](https://rustup.rs/) and [trunk](https://trunkrs.dev). Then run the following commands in separate terminals:
``` ```
# start backend, with separate target folder to avoid rebuilds from arch change # start backend
cargo run --target-dir target/backend cargo run
# or with automatic rebuild on changes using cargo-watch
CARGO_TARGET_DIR=target/backend cargo watch -c -x run
# start frontend, automatic rebuild on changes # start frontend with automatic rebuild on changes
trunk serve -w src/frontend/ trunk serve -w src/frontend/
``` ```
Then open the site at [127.0.0.1:8080](http://127.0.0.1:8080/). Then open the site at [127.0.0.1:8080](http://127.0.0.1:8080/). Alternatively you can run `./scripts/watch.sh` to rebuild backend and frontend automatically on code changes (requires [cargo-watch](https://crates.io/crates/cargo-watch)).
## License ## License

11
scripts/watch.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
# run processes in parallel
# https://stackoverflow.com/a/52033580
(trap 'kill 0' SIGINT;
# start frontend
trunk serve -w src/frontend/ &
# # start backend, with separate target folder to avoid rebuilds from arch change
CARGO_TARGET_DIR=target/backend cargo watch -c -x run
)