Package
#n Wyam.Sass
Examples
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)
);
Usage
Sass()
Fluent Methods
Chain these methods together after the constructor to modify behavior.
-
GenerateSourceMap(bool generateSourceMap = true)Specifies whether a source map should be generated (the default behavior is
false).generateSourceMaptrueto generate a source map.
-
IncludeSourceComments(bool includeSourceComments = true)Sets whether the source comments are included (by default they are not).
includeSourceCommentstrueto include source comments.
-
WithCompactOutputStyle()Sets the output style to compact.
-
WithCompressedOutputStyle()Sets the output style to compressed.
-
WithExpandedOutputStyle()Sets the output style to expanded.
-
WithImportPath(Func<string, string> importPathFunc)A delegate that processes the path in
@importstatements.importPathFuncA delegate that should return the correct import path for a given import.
-
WithIncludePaths(params DirectoryPath[] paths)Adds a list of paths to search while processing includes.
pathsThe paths to include.
-
WithInputPath(DocumentConfig inputPath)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.RelativeFilePathmetadata value is used for the input document path.inputPathA delegate that should return a
Wyam.Common.IO.FilePath.
-
WithNestedOutputStyle()Sets the output style to nested.
Input Metadata
The metadata values listed below apply to individual documents and are typically set from front matter (with just the name of the key) and used as inputs to the module to control behavior.
-
Keys.RelativeFilePath:Wyam.Common.IO.FilePathIf
Wyam.Common.Meta.Keys.SourceFilePathis unavailable, this is used to guess at the source file path. -
Keys.SourceFilePath:Wyam.Common.IO.FilePathThe default key to use for determining the input document path.
Output Metadata
The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.
-
Keys.RelativeFilePath:Wyam.Common.IO.FilePathRelative path to the output CSS (or map) file.
-
Keys.WritePath:Wyam.Common.IO.FilePathThe path to use when writing the file.
