A simple build task for compiling Sass files in your MSBuild project.
Easy to configure via familiar JSON-based config file.
Cross-platform alternative to the WebCompiler.
- .NET Core SDK 3 or later, or .NET Framework 4.7.2 or later.
- Latest version of Sass installed on your computer.
Just add a reference to the SassTask package in your project.
dotnet add package SassTask --version 0.2.0-*
The build task is then automatically imported.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<SassConfigPath Condition="'$(Configuration)'=='Debug'">sassconfig.debug.json</SassConfigPath>
<SassConfigPath Condition="'$(Configuration)'=='Release'">sassconfig.json</SassConfigPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SassTask" Version="0.2.0-*" PrivateAssets="All" />
</ItemGroup>
</Project>
The file extensions recogzined by the build task are .sass
and .scss
.
The build task can be confgured in the sassconfig.json
file.
By default, it is expected to be in the project directory.
The default settings are:
{
"compilerOptions": {
"style": "expanded",
"update": false,
"sourceMap": true,
"sourceMapUrls": "relative",
"embedSources": false,
"embedSourceMap": false,
"sourceDir": ".",
"outDir": "."
},
"files": undefined
}
- compilerOptions
- style ("expanded" | "compressed") - the style of the output.
- update - indicating that only files that have changed should be compiled.
- sourceMap - indicating whether a source map should be created or not.
- sourceMapUrls ("relative" | "absolute") - the type of paths to source files.
- embedSources - embed sources in the resulting CSS-files.
- embedSourceMap - embed source map in the resulting CSS-files.
- sourceDir - the directory in which the sass-files are located.
- outDir - the directory to output css-files in.
- files - an array of file paths that will be exclusively included as input. Wildcards are accepted.
To build this solution:
- Install .NET Core CLI 3.0.0 or greater. See https://dot.net/core for download links.
- Run
./build.ps1
in PowerShell or./build.sh
from Bash.