-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.rs
34 lines (29 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
33
34
use glob::glob;
use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::Command;
fn main() {
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
let is_debug = env::var_os("PROFILE") == Some("debug".into());
let src: &str = "sass/main.scss";
let dst: &str = "main.css";
let out_dir: PathBuf = PathBuf::from(env::var_os("OUT_DIR").unwrap());
for entry in glob("sass/**/*.scss").expect("Failed to glob") {
println!("cargo:rerun-if-changed={}", entry.unwrap().display());
}
/* Compress css in release mode */
let options = grass::Options::default().style(if is_debug {
grass::OutputStyle::Expanded
} else {
grass::OutputStyle::Compressed
});
let css = grass::from_path(src, &options).unwrap();
let dst = out_dir.join(dst);
fs::write(dst, &css).unwrap();
}