Sass Compilation

Main types for using the Sass compiler.


Topics

Compiler

actor Compiler

A Sass compiler that uses Dart Sass as an embedded child process.

The Dart Sass compiler is bundled with this package for macOS and Ubuntu 64-bit Linux. For other platforms you need to supply this separately, see the readme.

Some debug logging is available via Compiler.logger.

You must shut down the compiler using shutdownGracefully(...) before the last reference to the object is released otherwise the program will exit.

Custom importer resolution

Dart Sass uses a different algorithm to LibSass for processing imports. Each stylesheet is associated with the importer that loaded it – this may be an internal or hidden filesystem importer. Import resolution then goes:

  • Consult the stylesheet’s associated importer.
  • Consult every DartSass.ImportResolver given to the compiler, first the global list then the per-compilation list, in order within each list.
Declaration
Swift
public actor Compiler

Inputs

enum Syntax

Declaration
Swift
public enum Syntax: Sendable

enum CssStyle

How the Sass compiler should format the CSS it produces.

Declaration
Swift
public enum CssStyle: Sendable

enum SourceMapStyle

The kind of source map to generate for the stylesheet, returned in CompilerResults.sourceMap.

Declaration
Swift
public enum SourceMapStyle: Sendable

enum CompilerMessageStyle

Declaration
Swift
public enum CompilerMessageStyle: Sendable

enum CompilerWarningLevel

A control over warnings and debug messages produced by the compiler

Declaration
Swift
public enum CompilerWarningLevel: Sendable

Outputs

struct CompilerResults

The output from a successful compilation.

Declaration
Swift
public struct CompilerResults: Sendable

struct CompilerMessage

A diagnostic message generated by the Sass compiler that does not prevent the compilation from succeeding.

Appropriate for display to end users who own the stylesheets.

Declaration
Swift
public struct CompilerMessage: CustomStringConvertible, Sendable

struct CompilerError

Thrown as an error after a failed compilation.

Declaration
Swift
public struct CompilerError: Swift.Error, CustomStringConvertible, Sendable

struct Span

A section of a stylesheet.

Declaration
Swift
public struct Span: CustomStringConvertible, Sendable