diff --git a/Cargo.lock b/Cargo.lock index 622df0c..be62712 100644 Binary files a/Cargo.lock and b/Cargo.lock differ diff --git a/crates/pinakes-ui/Cargo.toml b/crates/pinakes-ui/Cargo.toml index 6c52e77..991a764 100644 --- a/crates/pinakes-ui/Cargo.toml +++ b/crates/pinakes-ui/Cargo.toml @@ -38,3 +38,6 @@ default = ["web"] web = ["dioxus/web"] desktop = ["dioxus/desktop"] mobile = ["dioxus/mobile"] + +[build-dependencies] +grass = "0.13" diff --git a/crates/pinakes-ui/build.rs b/crates/pinakes-ui/build.rs new file mode 100644 index 0000000..22fa64d --- /dev/null +++ b/crates/pinakes-ui/build.rs @@ -0,0 +1,33 @@ +#![expect( + clippy::expect_used, + reason = "build scripts conventionally panic on failure; there is no caller \ + to propagate errors to" +)] + +use std::{fs, path::Path}; + +fn main() { + // Compile SCSS to CSS + let scss_dir = Path::new("assets/styles"); + let css_dir = Path::new("assets/css"); + + // Create CSS output directory if it doesn't exist + fs::create_dir_all(css_dir).expect("Failed to create CSS directory"); + + // Compile main.scss + let scss_input = scss_dir.join("main.scss"); + let css_output = css_dir.join("main.css"); + + if scss_input.exists() { + let css = grass::from_path( + &scss_input, + &grass::Options::default().style(grass::OutputStyle::Compressed), + ) + .expect("Failed to compile SCSS"); + + fs::write(&css_output, css).expect("Failed to write CSS"); + + // Tell cargo to rerun if SCSS files change + println!("cargo:rerun-if-changed=assets/styles"); + } +} diff --git a/crates/pinakes-ui/src/styles.rs b/crates/pinakes-ui/src/styles.rs index 9f8ad3e..197ae0b 100644 --- a/crates/pinakes-ui/src/styles.rs +++ b/crates/pinakes-ui/src/styles.rs @@ -1,7 +1,8 @@ //! Styles module for Pinakes UI //! -//! Exports the SCSS asset for use with Dioxus. +//! Exports the CSS asset for use with Dioxus. +//! SCSS files are compiled to CSS via build.rs. use dioxus::prelude::*; -pub static STYLES: Asset = asset!("/assets/styles/main.scss"); +pub static STYLES: Asset = asset!("/assets/css/main.css");