Sass Compilation
Main types for using the Sass compiler.
Topics
Compiler
actor 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 a swift-log Logger that produces goodpath protocol and compiler lifecycle tracing at Logger.Level.debug log level, approx 300 bytes per compile request, and protocol and lifecycle error reporting at Logger.Level.debug log level for conditions that are also reported through errors thrown from some API.
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
public actor Compiler
Inputs
enum Syntax
enum Syntax
enum CssStyle
enum CssStyle
How the Sass compiler should format the CSS it produces.
Declaration
public enum CssStyle: Sendable
enum SourceMapStyle
enum SourceMapStyle
The kind of source map to generate for the stylesheet, returned in CompilerResults.sourceMap
.
Declaration
public enum SourceMapStyle: Sendable
enum CompilerMessageStyle
enum CompilerMessageStyle
The format used for CompilerError.description
and CompilerMessage.description
.
Declaration
public enum CompilerMessageStyle: Sendable
enum CompilerWarningLevel
enum CompilerWarningLevel
A control over warnings and debug messages produced by the compiler
Declaration
public enum CompilerWarningLevel: Sendable
enum Deprecation
enum Deprecation
A Deprecation
refers to a specific feature of the Sass compiler that is deprecated or planned to
become deprecated.
By default, using a deprecated feature causes a warning – that is, a CompilerMessage
with
type CompilerMessage.Kind.deprecation
. In some future release of the compiler,
use of the deprecated feature will cause an error instead.
You can customize a Sass Compiler
’s treatment of deprecated behaviours using a DeprecationControl
to create the compiler instance. Each individual deprecation can be ignored or promoted to an error. You can also
opt in to future deprecations – features that do not currently cause a deprecation warning but are planned to do
so in an upcoming release of Dart Sass.
Declaration
public enum Deprecation: Hashable, Sendable, CustomStringConvertible
struct DeprecationControl
struct DeprecationControl
A Compiler
’s deprecation settings.
Indicates which Deprecation
s should be fatal, silenced, or eagerly adopted.
Declaration
public struct DeprecationControl: Sendable
Outputs
struct CompilerResults
struct CompilerResults
struct CompilerMessage
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
public struct CompilerMessage: CustomStringConvertible, Sendable
struct CompilerError
struct CompilerError
Thrown as an error after a failed compilation.
Declaration
public struct CompilerError: Swift.Error, CustomStringConvertible, Sendable
struct Span
struct Span