aboutsummaryrefslogtreecommitdiffstats
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/build.rs b/build.rs
index e65b294..75cc3e2 100644
--- a/build.rs
+++ b/build.rs
@@ -2,18 +2,39 @@ use std::env;
use std::fs;
use std::path::Path;
+const THEMES: &[&str] = &["squirrel", "archlinux", "zenburn", "monokai"];
+
fn main() {
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env var missing");
+
let dest_path = Path::new(&out_dir).join("style.css");
fs::write(
dest_path,
- grass::from_string(
- include_str!("data/style.scss").to_string(),
- &grass::Options::default(),
- )
- .expect("scss failed to compile"),
+ grass::from_path("data/style.scss", &grass::Options::default())
+ .expect("scss failed to compile"),
)
.expect("failed to write css file");
+ for theme in THEMES.iter() {
+ let dest_path = Path::new(&out_dir).join(format!("theme-{}.css", theme));
+ fs::write(
+ dest_path,
+ grass::from_string(
+ format!(
+ r#"
+ @use "data/themes/{theme}";
+ body:not([data-theme]) {{
+ @include {theme}.theme();
+ }}
+ "#,
+ theme = theme
+ ),
+ &grass::Options::default(),
+ )
+ .expect("scss failed to compile"),
+ )
+ .expect("failed to write css file");
+ }
+
println!("cargo:rerun-if-changed=data/style.scss");
}