-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rs
32 lines (25 loc) · 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
use railwind::{Source, SourceOptions};
use std::{env, path::Path};
fn main() {
// Without this, adding only a migration will not trigger a re-build
// https://docs.rs/sqlx/latest/sqlx/macro.migrate.html#stable-rust-cargo-build-script
println!("cargo:rerun-if-changed=migrations");
println!("cargo:rerun-if-changed=templates");
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("railwind.css");
let paths: Vec<_> = walkdir::WalkDir::new("templates")
.into_iter()
.map(|e| e.expect("Error while searching for templates"))
.filter(|e| e.file_type().is_file())
.map(|entry| entry.into_path())
.collect();
let templates = paths
.iter()
.map(|p| SourceOptions {
input: p,
option: railwind::CollectionOptions::Html,
})
.collect();
let source = Source::Files(templates);
railwind::parse_to_file(source, dest_path.to_str().unwrap(), false, &mut Vec::new());
}