2019-07-26 14:21:53 +02:00
|
|
|
// Generates static assets.
|
|
|
|
|
|
|
|
use std::env;
|
2020-07-14 21:42:30 +02:00
|
|
|
use std::error::Error;
|
2019-07-26 14:21:53 +02:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Write;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use sass_rs::{self, Options};
|
|
|
|
|
2020-07-14 21:42:30 +02:00
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
2019-07-26 14:21:53 +02:00
|
|
|
let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
let scss_dir = Path::new(&dir).join("scss");
|
|
|
|
let source_css_file = scss_dir.join("stoptime.scss");
|
|
|
|
let css_dir = Path::new(&dir).join("static").join("css");
|
|
|
|
let target_css_file = css_dir.join("stoptime.css");
|
|
|
|
|
2020-07-14 21:42:30 +02:00
|
|
|
let sass = sass_rs::compile_file(&source_css_file, Options::default())
|
|
|
|
.map_err(|err| format!("Sass compilation failed: {}", err))?;
|
2019-07-26 14:21:53 +02:00
|
|
|
let mut f = File::create(&target_css_file).unwrap();
|
|
|
|
f.write_all(sass.as_bytes()).unwrap();
|
2020-07-14 21:42:30 +02:00
|
|
|
Ok(())
|
2019-07-26 14:21:53 +02:00
|
|
|
}
|