use lightningcss::{
bundler::{Bundler, FileProvider},
stylesheet::ParserOptions,
stylesheet::PrinterOptions,
};
use std::{env, error::Error, fs::File, io::Write, path::Path};
fn main() -> Result<(), Box<dyn Error>> {
let fs = FileProvider::new();
let mut bundler = Bundler::new(&fs, None, ParserOptions::default());
let stylesheet = bundler.bundle(Path::new("templates/style.css")).unwrap();
let styles_result = stylesheet.to_css(PrinterOptions {
minify: true,
..PrinterOptions::default()
})?;
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("style.css");
let mut main_rs = File::create(&dest_path)?;
write!(&mut main_rs, "{}", styles_result.code)?;
Ok(())
}