![]() |
VOOZH | about |
dotnet add package AspNetCore.SassCompiler --version 1.101.0
NuGet\Install-Package AspNetCore.SassCompiler -Version 1.101.0
<PackageReference Include="AspNetCore.SassCompiler" Version="1.101.0" />
<PackageVersion Include="AspNetCore.SassCompiler" Version="1.101.0" />Directory.Packages.props
<PackageReference Include="AspNetCore.SassCompiler" />Project file
paket add AspNetCore.SassCompiler --version 1.101.0
#r "nuget: AspNetCore.SassCompiler, 1.101.0"
#:package AspNetCore.SassCompiler@1.101.0
#addin nuget:?package=AspNetCore.SassCompiler&version=1.101.0Install as a Cake Addin
#tool nuget:?package=AspNetCore.SassCompiler&version=1.101.0Install as a Cake Tool
Sass Compiler Library for .NET 6 and above, without node.
The installation of this package is quite simple, you can install this package using NuGet with the following command:
# Package Manager
PM> Install-Package AspNetCore.SassCompiler
# .NET CLI
dotnet add package AspNetCore.SassCompiler
After adding the package, the Sass styles from the Source (defaults to: Styles) will automatically be compiled into .css files in the TargetFolder (defaults to: wwwroot\css) on build.
You can also adjust the default configuration in the appsettings.json or sasscompiler.json, do note that when using appsettings.json the configuration needs to be nested under a "SassCompiler" property, but when you're using sasscompiler.json the settings should not be nested.
| Name | Default value | Description |
|---|---|---|
| Source | "Styles" | The folder where all the .scss files reside, or an scss file |
| Target | "wwwroot/css" | When Source is a folder, the folder to output the generated .css files to<br/>When Source is a file, the .css filepath where to save the css file |
| Arguments | "--error-css" | Arguments passed to the dart-sass executable. see here for available arguments. |
| GenerateScopedCss | true | Enable/disable support for scoped scss |
| ScopedCssFolders | ["Views", "Pages", "Shared", "Components"] | The folders in which .scss files are considered for scoped css |
| IncludePaths | [] | Add folders to search in when importing modules |
| Compilations | [] | A list of source/target pairs that should be compiled. These will be added to the default Source and Target configured above. |
| Configurations | {} | Add configuration to override specific options based on the build conifguration (e.g. Debug/Release) |
<details open> <summary>appsettings.json</summary>
{
"SassCompiler": {
"Source": "Styles",
"Target": "wwwroot/css",
"Arguments": "--style=compressed",
"GenerateScopedCss": true,
"ScopedCssFolders": ["Views", "Pages", "Shared", "Components"],
"IncludePaths": [],
"Compilations": [
// Specify a specific file source/target in addition to the "Styles" -> "wwwroot/css" Source/Target above
{ "Source": "wwwroot/scss/site.scss", "Target": "wwwroot/css/site.min.css" },
// Or an extra directory to a different target directory
{ "Source": "Lib/Styles", "Target": "wwwroot/lib/css" }
],
// You can override specific options based on the build configuration
"Configurations": {
"Debug": { // These options apply only to Debug builds
"Arguments": "--style=expanded"
}
}
}
}
</details>
<details> <summary>sasscompiler.json</summary>
{
"Source": "Styles",
"Target": "wwwroot/css",
"Arguments": "--style=compressed",
"GenerateScopedCss": true,
"ScopedCssFolders": ["Views", "Pages", "Shared", "Components"],
"IncludePaths": [],
"Compilations": [
// Specify a specific file source/target in addition to the "Styles" -> "wwwroot/css" Source/Target above
{ "Source": "wwwroot/scss/site.scss", "Target": "wwwroot/css/site.min.css" },
// Or an extra directory to a different target directory
{ "Source": "Lib/Styles", "Target": "wwwroot/lib/css" }
],
// You can override specific options based on the build configuration
"Configurations": {
"Debug": { // These options apply only to Debug builds
"Arguments": "--style=expanded"
}
}
}
</details>
To use the Sass watcher in your project, you must add the following code to your startup.cs:
public void ConfigureServices(IServiceCollection services)
{
#if DEBUG
services.AddSassCompiler();
#endif
}
We recommend adding the #if DEBUG statement to only use a watcher during debug mode.
Note: The Sass watcher is currently not supported inside of a docker container. This should only be an issue when you're developing inside of a docker container, running the published application in docker is supported as the compiler is automatically run during the MSBuild publish step. See this issue for the progress.
If you use this with Blazor WebAssembly and want to customize the settings you need to use the sasscompiler.json, using appsettings.json is not supported. The sass watcher is currently not supported for Blazor WebAssembly projects, the MSBuild task is still available and will compile your scss during build and publish.
It is also possible to compile SCSS files at runtime by using the ISassCompiler interface. By default however, the
sass executables are not included in a Release build. To make be able to use the ISassCompiler interface in production
you need to add the following property to your csproj file: <SassCompilerIncludeRuntime>true</SassCompilerIncludeRuntime>.
If you don't want to use the hosted service to automatically compile your scss files during development, but do want to
have the ISassCompiler available, you can use the AddSassCompilerCore() method instead of the AddSassCompiler()
method on the IServiceCollection. This will register what is required to use the ISassCompiler interface without
registering the hosted service.
If you are only using ISassCompiler at runtime and want to disable the MSBuild compile-on-build task entirely, you can
add the following property to your .csproj file:
<PropertyGroup>
<SassCompilerEnableBuildTask>false</SassCompilerEnableBuildTask>
</PropertyGroup>
This prevents the Sass MSBuild task from running during build and publish, while leaving ISassCompiler fully functional at runtime.
This library also includes an MSBuild task that runs during the publish of your application. Because of this you don't need to include the Sass Watcher in your release builds and you can safely add the generated .css files to the .gitignore file as they are regenerated during publish.
If you're publishing your application inside an alpine linux container, you will need to install gcompat (using apk add gcompat) before running dotnet build or dotnet publish.
This is needed because the dart runtime which is what the sass compiler uses requires this package on alpine linux.
Take a look at one of our examples on how it can be integrated in your project. We've created example projects for ASP.NET Core MVC, Blazor Server/Wasm and RazorClassLibrary projects.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on AspNetCore.SassCompiler:
| Package | Downloads |
|---|---|
|
JJMasterData.Web
JJMasterData is a codeless CRUD Generator from database metadata. This package contains the Data Dictionary Razor Class Library with all necessary packages. |
|
|
ThePensionsRegulator.GovUk.Frontend
Based on the GOV.UK Design System and GovUk.Frontend.AspNetCore. Adds extra features and components. |
|
|
ThePensionsRegulator.GovUk.Frontend.Umbraco
GOV.UK Design System components implemented using the block list editor in Umbraco, and classes used to build applications based on these components. |
|
|
ThePensionsRegulator.Frontend
Based on the GOV.UK Design System and GovUk.Frontend.AspNetCore. Adds extra components targeted at The Pensions Regulator including The Pensions Regulator branding. |
|
|
ThePensionsRegulator.Frontend.Umbraco
Umbraco support for components targeted at The Pensions Regulator. |
Showing the top 2 popular GitHub repositories that depend on AspNetCore.SassCompiler:
| Repository | Stars |
|---|---|
|
dotnetcore/BootstrapBlazor
Bootstrap Blazor is an enterprise-level UI component library based on Bootstrap and Blazor.
|
|
|
JJConsulting/JJMasterData
.NET CRUD generator library with Bootstrap support to create dynamic forms at runtime from a data dictionary.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.101.0 | 1,828 | 6/15/2026 |
| 1.100.0 | 18,036 | 5/26/2026 |
| 1.99.0 | 74,090 | 4/6/2026 |
| 1.98.0 | 10,874 | 3/27/2026 |
| 1.97.1 | 154,225 | 12/21/2025 |
| 1.97.0 | 13,360 | 12/17/2025 |
| 1.96.0 | 1,378 | 12/16/2025 |
| 1.95.1 | 6,461 | 12/10/2025 |
| 1.94.2 | 49,358 | 11/20/2025 |
| 1.94.1 | 1,427 | 11/18/2025 |
| 1.94.0 | 7,304 | 11/12/2025 |
| 1.93.3 | 13,792 | 11/3/2025 |
| 1.93.2 | 96,022 | 9/24/2025 |
| 1.93.1 | 1,677 | 9/23/2025 |
| 1.93.0 | 1,411 | 9/22/2025 |
| 1.92.1 | 14,791 | 9/8/2025 |
| 1.92.0 | 3,978 | 9/3/2025 |
| 1.91.0 | 40,226 | 8/26/2025 |
| 1.90.0 | 14,025 | 8/10/2025 |
| 1.89.2 | 81,193 | 6/10/2025 |