Sass Class

Summary

Compiles Sass CSS files to CSS stylesheets.
Assembly
Wyam.Sass.dll
Namespace
Wyam.Sass
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type["Sass"] class Type type-node

Syntax

public class Sass : IModule

Examples

This is a pipeline that compiles two Sass CSS files, one for Bootstrap (which contains a lot of includes) and a second for custom CSS.
Pipelines.Add("Sass",
    ReadFiles("master.scss"),
    Concat(ReadFiles("foundation.scss")),
    Sass().WithCompactOutputStyle(),
    WriteFiles(".css")
);
Another common pattern is building Bootstrap from npm sitting alongside your "input" folder in a "node_modules" folder. This can be accomplished with a pipeline that looks similar to the following. It loads the Bootstrap Sass files that don't begin with "_" from the Bootstrap node module and then outputs the results to a specific path under your output folder (in this case, "assets/css/bootstrap.css").
Pipelines.Add("Bootstrap",
    ReadFiles("../node_modules/bootstrap/scss/**/{!_,}*.scss"),
    Sass()
        .WithCompactOutputStyle(),
    WriteFiles((doc, ctx) => $"assets/css/{doc.String(Keys.RelativeFilePath)}")
        .UseWriteMetadata(false)
);

Remarks

The content of the input document is compiled to CSS and the content of the output document contains the compiled CSS stylesheet.

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
GenerateSourceMap(bool) Sass
Specifies whether a source map should be generated (the default behavior is false).
IncludeSourceComments(bool) Sass
Sets whether the source comments are included (by default they are not).
WithCompactOutputStyle() Sass
Sets the output style to compact.
WithCompressedOutputStyle() Sass
Sets the output style to compressed.
WithExpandedOutputStyle() Sass
Sets the output style to expanded.
WithImportPath(Func<string, string>) Sass
A delegate that processes the path in @import statements.
WithIncludePaths(DirectoryPath[]) Sass
Adds a list of paths to search while processing includes.
WithInputPath(DocumentConfig) Sass
Specifies a delegate that should be used to get the input path for each input document. This allows the Sass processor to search the right file system and paths for include files. By default, the Wyam.Common.Meta.Keys.RelativeFilePath metadata value is used for the input document path.
WithNestedOutputStyle() Sass
Sets the output style to nested.
GitHub