fix!: bring const scopes back
Some checks failed
cargo basic build-test / Sabry - latest (push) Has been cancelled
cargo basic build-test / Sabry - latset - examples (push) Has been cancelled
cargo basic build-test / Sabry - latset - examples-1 (push) Has been cancelled
cargo basic build-test / Sabry - latset - examples-2 (push) Has been cancelled

- replace grass with sasso
- drop lightningcss
- rearrange crate and workspace hierarchy & features
This commit is contained in:
spushk 2026-10-11 22:57:27 +03:00
commit 0a0cbeee1a
Signed by untrusted user who does not match committer: spushk
GPG key ID: 7797B761E105E8AA

View file

@ -0,0 +1,49 @@
use crate::{conf::SabryConfig, style::syntax::SyntaxKind};
/// Convenience wrapper on Grass and Lightningcss
pub struct CompilerAdapter {
#[allow(dead_code)] // without 'compile' feature, still want to set this
config: SabryConfig,
}
impl CompilerAdapter {
pub fn new(config: SabryConfig) -> Self {
Self { config }
}
/// Compile given SASS/SCSS into CSS
/// with respect to self.config
pub fn compile_module(
&self,
syntax: SyntaxKind,
code: &str,
) -> Result<String, SabryCompilerError> {
let importer = sasso::FsImporter::new(self.config.sass.modules.clone().unwrap_or_default());
let options = sasso::Options::new()
.with_style(if self.config.css.minify {
sasso::OutputStyle::Compressed
} else {
sasso::OutputStyle::Expanded
})
.with_importer(&importer)
.with_syntax(syntax.into());
Ok(sasso::compile(code, &options)?)
}
}
#[derive(thiserror::Error)]
pub enum SabryCompilerError {
#[error("Could not compile into CSS with sasso")]
Compile(#[from] sasso::Error),
}
impl std::fmt::Debug for SabryCompilerError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let explain = match self {
Self::Compile(err) => format!("{err}"),
};
write!(f, "{explain}")
}
}