Skip to main content

Crate sasso

Crate sasso 

Source
Expand description

sasso — a pure-Rust SCSS → CSS compiler.

A small, zero-dependency, embeddable Sass engine aiming at byte-exact parity with current dart-sass on the subset it implements (e.g. computed colors serialize as rgb(63.75, 127.5, 191.25), not rounded hex). It is sandbox-friendly: @import resolution goes through a caller-supplied Importer, so an embedder controls all file access.

§Example

use sasso::{compile, Options};

let css = compile("$c: #333; a { color: $c; &:hover { color: $c; } }", &Options::default()).unwrap();
assert!(css.contains("a {"));
assert!(css.contains("a:hover {"));

§Scope

This covers a large slice of Sass: variables (!default/!global), nesting and the & parent selector, #{} interpolation, // and /* */ comments, unit arithmetic, the color functions, control flow, mixins/functions, @extend, @import, and the @use/@forward module system. Both input syntaxes are supported — the brace/semicolon SCSS syntax and the indented .sass syntax (selected via Options::with_syntax or, in the CLI, the input file’s extension) — parsing into the same AST and sharing the evaluator and emitter. The north-star target is 100% of the official sass-spec suite, tracked by the harness in spec/.

Structs§

Error
A compilation error, carrying a human-readable message and a 1-based source position (line/col are 0 when the position is unknown).
FsImporter
A filesystem Importer resolving Sass partials (_name.scss, name/_index.scss) against a list of load paths.
Options
Compilation options.
ScopedAlloc
A scoped bump global allocator. Inside a compile() scope it bump-allocates from a per-thread arena that is reset when the scope ends; outside any scope it forwards to the system allocator. Install it in a binary or wasm wrapper:

Enums§

OutputStyle
Output formatting style.
Syntax
The input syntax flavour.

Traits§

Importer
Resolves @import arguments to SCSS source.

Functions§

compile
Compile SCSS source to CSS.
set_arena_bytes
Override the wasm arena reservation size, in bytes. Must be called BEFORE the first compile() — the region is reserved on first use and then fixed, so a later call has no effect. 0 disables the arena entirely (every allocation forwards to the system allocator: lower memory, slower). No effect on native targets (they always use the 2 GiB virtual reservation).