-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
40 lines (33 loc) · 1.1 KB
/
build.rs
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
36
37
38
39
40
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=assets");
println!("cargo:rerun-if-changed=templates");
println!("cargo:rerun-if-changed=migrations");
std::fs::remove_dir_all("static").unwrap_or_default();
Command::new("tailwindcss")
.args([
"-c",
"tailwind.config.js",
"-i",
"assets/styles/index.css",
"-o",
"static/index.css",
"--minify",
])
.status()
.expect("failed to run tailwindcss");
copy_files("public");
}
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!("static/{}", filename);
std::fs::copy(path, dest).expect("failed to copy file");
}
}
}