diff options
author | Bao Trinh <qubidt@gmail.com> | 2023-07-12 17:46:51 +0000 |
---|---|---|
committer | Bao Trinh <qubidt@gmail.com> | 2023-07-12 18:39:51 +0000 |
commit | b369a1a9ff3c60b67a7598d4486253c428e3a4da (patch) | |
tree | 2cdf9586cc50f999fc69f436aea89c5ff3332cba /build.rs | |
parent | simplify theme selection using data attributes (diff) | |
download | miniserve-b369a1a9ff3c60b67a7598d4486253c428e3a4da.tar.gz miniserve-b369a1a9ff3c60b67a7598d4486253c428e3a4da.zip |
Separate color schemes into separate files
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -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"); } |