Skip to content

Commit

Permalink
Configure build.rs to rerun when frontend is modified
Browse files Browse the repository at this point in the history
  • Loading branch information
kobkaz committed Dec 8, 2023
1 parent 99b2a50 commit 3ae56d3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
52 changes: 52 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tmtc-c2a/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tonic-health = "0.10"
tonic-reflection = "0.10"
tonic-web = "0.10"
axum = { version = "0.6", default-features = false, features = ["http1", "tokio"] }
rust-embed = "8.0.0"
rust-embed = { version = "8.0.0", features = ["interpolate-folder-path"] }
mime_guess = "2.0.4"
sentry = { version = "0.31", default-features = false, features = ["backtrace", "contexts", "panic", "rustls", "reqwest"] }
sentry-tracing = "0.31"
Expand Down
7 changes: 5 additions & 2 deletions tmtc-c2a/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ fn main() {
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));

if std::env::var("SKIP_FRONTEND_BUILD").is_err() {
println!("cargo:rerun-if-changed=devtools_frontend");
let status = Command::new("yarn")
.current_dir("devtools_frontend")
.status()
.expect("failed to build frontend");
assert!(status.success());
let status = Command::new("yarn")
let out_dir = env::var("OUT_DIR").unwrap();
let status = Command::new("npx")
.current_dir("devtools_frontend")
.arg("build")
.arg("run-s")
.arg(&format!("build:vite -- --outDir {out_dir}/devtools_dist"))
.status()
.expect("failed to build frontend");
assert!(status.success());
Expand Down
2 changes: 1 addition & 1 deletion tmtc-c2a/src/devtools_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rust_embed::RustEmbed;
static INDEX_HTML: &str = "index.html";

#[derive(RustEmbed)]
#[folder = "./devtools_frontend/dist"]
#[folder = "$OUT_DIR/devtools_dist"]
struct Assets;

pub async fn serve(uri: Uri) -> Response {
Expand Down

0 comments on commit 3ae56d3

Please sign in to comment.