use std::path::Path;
const COMPILED_ASSETS: &[(&str, &str)] = &[
("static/css/output.css", "npm run build-css"),
("static/js/editor.bundle.js", "npm run build-js"),
];
fn main() {
let mut missing = Vec::new();
for (path, command) in COMPILED_ASSETS {
println!("cargo:rerun-if-changed={path}");
if !Path::new(path).exists() {
missing.push((path, command));
}
}
if missing.is_empty() {
return;
}
eprintln!("error: missing compiled front-end assets:");
for (path, command) in &missing {
eprintln!(" - {path} (generate with: {command})");
}
eprintln!(
"\n\
These files are generated and not checked into git, so they are absent\n\
from git clones and source tarballs. Building them requires Node.js:\n\
\n\
\tnpm install\n\
\tnpm run build-css\n\
\tnpm run build-js\n\
\n\
Without them the web UI (`cook server`, `cook build web`) renders\n\
unstyled pages. Alternatively, install from crates.io with\n\
`cargo install cookcli` — the published package ships the compiled\n\
assets prebuilt."
);
std::process::exit(1);
}