use std::fs; use std::path::PathBuf; use std::process::Command; fn main() { println!("cargo:rerun-if-changed=templates"); println!("cargo:rerun-if-changed=assets"); println!("cargo:rerun-if-changed=tailwind.config.js"); fs::remove_dir_all("resources").unwrap_or_default(); let bun_install = std::env::var("BUN_INSTALL").expect("BUN_INSTALL not set"); println!("BUN_INSTALL: {}", bun_install); let bun_exe = PathBuf::from(&bun_install).join("bin/bun"); let bun_exe = fs::canonicalize(bun_exe).unwrap(); println!("Bun Exe: {}", bun_exe.display()); Command::new(bun_exe) .args([ "run", "tailwindcss", "-c", "tailwind.config.js", "-i", "assets/public/css/tailwind.css", "-o", "resources/main.css", "--minify", ]) .status() .expect("failed to run tailwindcss"); copy_files("assets/static"); } fn copy_files(dir: &str) { for entry in std::fs::read_dir(dir).expect("failed to read dir `public`") { let entry = entry.expect("failed to read entry"); if entry.file_type().unwrap().is_dir() { copy_files(entry.path().to_str().unwrap()); } else { let path = entry.path(); let filename = path.file_name().unwrap().to_str().unwrap(); let dest = format!("resources/{}", filename); std::fs::copy(path, dest).expect("failed to copy file"); } } }