-
Notifications
You must be signed in to change notification settings - Fork 77
/
build.rs
43 lines (35 loc) · 933 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
38
39
40
41
42
43
use std::path::PathBuf;
use rsass::{compile_scss_path, output::{Format, Style}};
use std::fs;
fn get_input_path(filename: &str) -> PathBuf {
let mut path = PathBuf::with_capacity(50);
path.push(".");
path.push("styles");
path.push(filename);
path.set_extension("scss");
path
}
fn get_output_path(filename: &str) -> PathBuf {
let mut path = PathBuf::with_capacity(50);
path.push(".");
path.push("static");
path.push(filename);
path.set_extension("css");
path
}
fn main () {
println!("cargo:rerun-if-changed=styles");
let entrypoints = ["index"];
for filename in &entrypoints {
let input_path = get_input_path(filename);
let css = compile_scss_path(
&input_path,
Format {
style: Style::Expanded,
..Default::default()
}
).unwrap();
let output_path = get_output_path(filename);
fs::write(output_path, css).unwrap();
}
}