LigerShark.WebOptimizer.Sass 3.0.136

Prefix Reserved
dotnet add package LigerShark.WebOptimizer.Sass --version 3.0.136
                    
NuGet\Install-Package LigerShark.WebOptimizer.Sass -Version 3.0.136
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LigerShark.WebOptimizer.Sass" Version="3.0.136" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LigerShark.WebOptimizer.Sass" Version="3.0.136" />
                    
Directory.Packages.props
<PackageReference Include="LigerShark.WebOptimizer.Sass" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LigerShark.WebOptimizer.Sass --version 3.0.136
                    
#r "nuget: LigerShark.WebOptimizer.Sass, 3.0.136"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LigerShark.WebOptimizer.Sass@3.0.136
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LigerShark.WebOptimizer.Sass&version=3.0.136
                    
Install as a Cake Addin
#tool nuget:?package=LigerShark.WebOptimizer.Sass&version=3.0.136
                    
Install as a Cake Tool

A Scss compiler for ASP.NET Core

Build status NuGet

This package compiles Sass/Scss into CSS by hooking into the LigerShark.WebOptimizer pipeline.

Install

Add the NuGet package LigerShark.WebOptimizer.Sass to any ASP.NET Core project supporting .NET Standard 2.0 or higher.

> dotnet add package LigerShark.WebOptimizer.Sass

Since the original library is written in JavaScript, you will need a JS engine to run it. As a JS engine is used the JavaScript Engine Switcher library. First of all, you need to install the JavaScriptEngineSwitcher.Extensions.MsDependencyInjection package which makes registration of JS engines more convenient. Then you need to install one of the NuGet packages containing a JS engine provider:

After installing the packages, you will need to register the default JS engine.

Versions

Master is being updated for ASP.NET Core 3.0 For ASP.NET Core 2.x, use the 2.0 branch.

Usage

Here's an example of how to compile a.scss and b.scss from inside the wwwroot folder and bundle them into a single .css file called /all.css:

In Startup.cs, modify the ConfigureServices method:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    // Add JavaScriptEngineSwitcher services to the services container.
    services.AddJsEngineSwitcher(options =>
    {
        options.AllowCurrentProperty = false;
        options.DefaultEngineName = V8JsEngine.EngineName;
    })
        .AddV8()
        ;

    services.AddWebOptimizer(pipeline =>
    {
        pipeline.AddScssBundle("/all.css", "a.scss", "b.scss");
    });
}

...and add app.UseWebOptimizer() to the Configure method anywhere before app.UseStaticFiles, like so:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseWebOptimizer();

    app.UseStaticFiles();
    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}

Now the path http://domain/all.css will return a compiled, bundled and minified CSS document based on the two source files.

You can also reference any .scss files directly in the browser (http://domain/a.scss) and a compiled and minified CSS document will be served. To set that up, do this:

services.AddWebOptimizer(pipeline =>
{
    pipeline.CompileScssFiles();
});

Or if you just want to limit what .scss files will be compiled, do this:

services.AddWebOptimizer(pipeline =>
{
    pipeline.CompileScssFiles("/path/file1.scss", "/path/file2.scss");
});

Setup TagHelpers

In _ViewImports.cshtml register the TagHelpers by adding @addTagHelper *, WebOptimizer.Core to the file. It may look something like this:

The TagHelpers are required in order for cache-busting version strings to be appended to the url. The ASP.NET LinkTagHelper attribute asp-append-version="true" is ignored.

@addTagHelper *, WebOptimizer.Core
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LigerShark.WebOptimizer.Sass:

Package Downloads
Blazura

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on LigerShark.WebOptimizer.Sass:

Repository Stars
madskristensen/Miniblog.Core
An ASP.NET Core blogging engine
madskristensen/PhotoGallery
ASP.NET Core Photo Gallery
Version Downloads Last Updated
3.0.136 542 9/10/2025
3.0.123 130,690 8/8/2024
3.0.120 10,030 7/29/2024
3.0.118 63,434 4/3/2024
3.0.115 63,306 2/6/2024
3.0.102 23,557 10/16/2023
3.0.99 353,002 6/19/2023
3.0.97 10,537 5/22/2023
3.0.91 211,784 7/20/2022
3.0.84 46,975 3/21/2022
3.0.82-beta 23,882 1/21/2022
3.0.81-beta 385 1/20/2022
3.0.77-beta 5,456 1/13/2022
3.0.75-beta 8,957 1/12/2022
3.0.73-beta 1,065 1/3/2022
3.0.58-beta 60,318 5/4/2021
3.0.43-beta 40,680 7/14/2020
3.0.42-beta 10,222 5/28/2020
3.0.40-beta 81,326 9/25/2019
1.0.34-beta 33,590 2/8/2018
1.0.33-beta 27,606 10/16/2017
1.0.32-beta 1,175 8/24/2017
1.0.30-beta 1,033 8/23/2017
1.0.29-beta 997 8/23/2017
1.0.28-beta 1,020 8/22/2017
1.0.25-beta 1,019 8/21/2017
1.0.23-beta 1,042 8/21/2017
1.0.22-beta 1,050 8/15/2017
1.0.19-beta 1,054 8/11/2017
1.0.18-beta 1,065 8/11/2017
1.0.16-beta 1,052 8/10/2017
1.0.15-beta 1,066 8/10/2017
1.0.12-beta 1,035 8/7/2017
1.0.10-beta 1,052 8/4/2017