use std::error::Error; use std::fs::{self, File}; use std::io::Write; use std::path::Path; use lightningcss::printer::PrinterOptions; use lightningcss::stylesheet::{self, ParserOptions, StyleSheet}; fn main() -> Result<(), Box> { let scss_path = Path::new("styles/global.scss"); let css_output_path = Path::new("public/styles/global.css"); if let Some(parent) = css_output_path.parent() { fs::create_dir_all(parent)?; } let css = grass::from_path(scss_path, &grass::Options::default()) .map_err(|e| Box::new(e) as Box)?; let stylesheet = StyleSheet::parse(&css, ParserOptions::default()).unwrap(); let minified_css = stylesheet.to_css(PrinterOptions { minify: true, ..PrinterOptions::default() }).unwrap(); let mut output_file = File::create(css_output_path)?; output_file.write_all(minified_css.code.as_bytes())?; Ok(()) }