1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{io::Write, path::Path};
use walkdir::WalkDir;
pub fn build_library() {
let out_dir = std::env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("all.rs");
let mut file = std::fs::File::create(&dest_path).unwrap();
for entry in WalkDir::new("./src").into_iter().filter_map(|e| e.ok()) {
if entry.metadata().unwrap().is_file() {
let source = std::fs::read_to_string(entry.path()).unwrap();
file.write_all(source.as_bytes()).unwrap();
}
}
}
pub fn build_frontend() {
let target = std::env::var_os("OUT_DIR").unwrap();
let target_dir = Path::new(&target).parent().unwrap().parent().unwrap();
std::process::Command::new("tailwindcss")
.arg("--content")
.arg(format!(
"{}/**/*.rs,./src/**/*.{{html,rs}},./index.html",
target_dir.display(),
))
.arg("-o")
.arg("./tailwind.css")
.arg("--minify")
.output()
.expect("failed to execute process");
println!("cargo:rerun-if-changed=./src");
}