LigerShark.WebOptimizer.Sass
3.0.120
Prefix Reserved
See the version list below for details.
dotnet add package LigerShark.WebOptimizer.Sass --version 3.0.120
NuGet\Install-Package LigerShark.WebOptimizer.Sass -Version 3.0.120
<PackageReference Include="LigerShark.WebOptimizer.Sass" Version="3.0.120" />
paket add LigerShark.WebOptimizer.Sass --version 3.0.120
#r "nuget: LigerShark.WebOptimizer.Sass, 3.0.120"
// Install LigerShark.WebOptimizer.Sass as a Cake Addin #addin nuget:?package=LigerShark.WebOptimizer.Sass&version=3.0.120 // Install LigerShark.WebOptimizer.Sass as a Cake Tool #tool nuget:?package=LigerShark.WebOptimizer.Sass&version=3.0.120
A Scss compiler for ASP.NET Core
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:
- JavaScriptEngineSwitcher.ChakraCore
- JavaScriptEngineSwitcher.Jint
- JavaScriptEngineSwitcher.Msie (only in the Chakra “Edge” JsRT mode)
- JavaScriptEngineSwitcher.V8
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:
@addTagHelper *, WebOptimizer.Core
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- DartSassHost (>= 1.0.13)
- JavaScriptEngineSwitcher.Core (>= 3.24.1)
- LigerShark.WebOptimizer.Core (>= 3.0.418)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on LigerShark.WebOptimizer.Sass:
Repository | Stars |
---|---|
madskristensen/PhotoGallery
ASP.NET Core Photo Gallery
|
Version | Downloads | Last updated |
---|---|---|
3.0.123 | 21,796 | 8/8/2024 |
3.0.120 | 3,290 | 7/29/2024 |
3.0.118 | 31,144 | 4/3/2024 |
3.0.115 | 37,690 | 2/6/2024 |
3.0.102 | 20,299 | 10/16/2023 |
3.0.99 | 172,982 | 6/19/2023 |
3.0.97 | 8,979 | 5/22/2023 |
3.0.91 | 172,762 | 7/20/2022 |
3.0.84 | 43,665 | 3/21/2022 |
3.0.82-beta | 21,810 | 1/21/2022 |
3.0.81-beta | 297 | 1/20/2022 |
3.0.77-beta | 5,119 | 1/13/2022 |
3.0.75-beta | 5,268 | 1/12/2022 |
3.0.73-beta | 920 | 1/3/2022 |
3.0.58-beta | 57,467 | 5/4/2021 |
3.0.43-beta | 39,564 | 7/14/2020 |
3.0.42-beta | 10,065 | 5/28/2020 |
3.0.40-beta | 77,602 | 9/25/2019 |
1.0.34-beta | 32,834 | 2/8/2018 |
1.0.33-beta | 26,761 | 10/16/2017 |
1.0.32-beta | 923 | 8/24/2017 |
1.0.30-beta | 777 | 8/23/2017 |
1.0.29-beta | 745 | 8/23/2017 |
1.0.28-beta | 778 | 8/22/2017 |
1.0.25-beta | 761 | 8/21/2017 |
1.0.23-beta | 793 | 8/21/2017 |
1.0.22-beta | 807 | 8/15/2017 |
1.0.19-beta | 803 | 8/11/2017 |
1.0.18-beta | 817 | 8/11/2017 |
1.0.16-beta | 798 | 8/10/2017 |
1.0.15-beta | 807 | 8/10/2017 |
1.0.12-beta | 781 | 8/7/2017 |
1.0.10-beta | 806 | 8/4/2017 |