-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
37 lines (27 loc) · 861 Bytes
/
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
use glob::glob;
use std::{
error::Error,
fs::{self, File},
io::Write,
};
use rsass::{compile_scss, output};
fn main() -> Result<(), Box<dyn Error>> {
let scss_output = "./static/.styles.css";
let mut scss = File::create(scss_output)?;
let mut contents =
String::from("/* This file is automatically generated, edits will be overwritten. */\n");
for entry in glob("src/**/*.scss").expect("Failed to read glob pattern") {
let path = entry?;
println!("Adding SCSS :{}", path.display());
let data = fs::read_to_string(path)?;
contents += data.as_ref();
}
let format = output::Format {
style: output::Style::Compressed,
..Default::default()
};
let css = compile_scss(contents.as_bytes(), format)?;
scss.write_all(&css)?;
scss.flush()?;
Ok(())
}