MudBlazor.SassCompiler
2.0.1
Prefix Reserved
See the version list below for details.
dotnet add package MudBlazor.SassCompiler --version 2.0.1
NuGet\Install-Package MudBlazor.SassCompiler -Version 2.0.1
<PackageReference Include="MudBlazor.SassCompiler" Version="2.0.1" />
paket add MudBlazor.SassCompiler --version 2.0.1
#r "nuget: MudBlazor.SassCompiler, 2.0.1"
// Install MudBlazor.SassCompiler as a Cake Addin #addin nuget:?package=MudBlazor.SassCompiler&version=2.0.1 // Install MudBlazor.SassCompiler as a Cake Tool #tool nuget:?package=MudBlazor.SassCompiler&version=2.0.1
Note
This is a MudBlazor fork of the excellent AspNetCore.SassCompiler package.
Please contribute any PRs and Issues to the original package.
AspNetCore.SassCompiler
Sass Compiler Library for .NET Core 3.1/5.x./6.x without node.
Installation
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
Configuration
After adding the package, the Sass styles from the SourceFolder (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.
Available options
Name | Default value | Description |
---|---|---|
SourceFolder | "Styles" | The folder where all the .scss files reside |
TargetFolder | "wwwroot/css" | The folder to output the generated .css files to |
Arguments | "--error-css" | Arguments passed to the dart-sass executable |
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 |
Examples
<details open> <summary>appsettings.json</summary>
{
"SassCompiler": {
"SourceFolder": "Styles",
"TargetFolder": "wwwroot/css",
"Arguments": "--style=compressed",
"GenerateScopedCss": true,
"ScopedCssFolders": ["Views", "Pages", "Shared", "Components"],
"IncludePaths": [],
// 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>
{
"SourceFolder": "Styles",
"TargetFolder": "wwwroot/css",
"Arguments": "--style=compressed",
"GenerateScopedCss": true,
"ScopedCssFolders": ["Views", "Pages", "Shared", "Components"],
"IncludePaths": [],
// You can override specific options based on the build configuration
"Configurations": {
"Debug": { // These options apply only to Debug builds
"Arguments": "--style=expanded"
}
}
}
</details>
Sass watcher
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.
Blazor WASM
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.
Publish
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.
Examples
To provide you with examples, a configured version of a .NET 5.0 project and a configured .NET 6.0 Blazor app are added in the /Samples folder. Please see the link below for quick access
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Configuration.Binder (>= 3.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Options (>= 3.1.0)
-
net5.0
- Microsoft.Extensions.Configuration.Binder (>= 3.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Options (>= 3.1.0)
-
net6.0
- Microsoft.Extensions.Configuration.Binder (>= 3.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Options (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.