snipervld.WebOptimizer.Dotless
3.3.0
dotnet add package snipervld.WebOptimizer.Dotless --version 3.3.0
NuGet\Install-Package snipervld.WebOptimizer.Dotless -Version 3.3.0
<PackageReference Include="snipervld.WebOptimizer.Dotless" Version="3.3.0" />
paket add snipervld.WebOptimizer.Dotless --version 3.3.0
#r "nuget: snipervld.WebOptimizer.Dotless, 3.3.0"
// Install snipervld.WebOptimizer.Dotless as a Cake Addin #addin nuget:?package=snipervld.WebOptimizer.Dotless&version=3.3.0 // Install snipervld.WebOptimizer.Dotless as a Cake Tool #tool nuget:?package=snipervld.WebOptimizer.Dotless&version=3.3.0
A LESS compiler for ASP.NET Core using dotless
This package compiles LESS files into CSS by hooking into the LigerShark.WebOptimizer pipeline.
Install
Add the NuGet package snipervld.WebOptimizer.Dotless to any ASP.NET Core project supporting .NET 6.0 or higher.
> dotnet add package snipervld.WebOptimizer.Dotless
Versions
Version | Support |
---|---|
>= 3.x | ASP.NET Core 6.0 and above |
Usage
Here's an example of how to compile a.less
and b.less
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();
services.AddWebOptimizer(pipeline =>
{
pipeline.AddLessBundle("/all.css", "a.less", "b.less");
});
}
...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 .less files directly in the browser (http://domain/a.less
) and a compiled and minified CSS document will be served. To set that up, do this:
services.AddWebOptimizer(pipeline =>
{
pipeline.CompileLessFiles();
});
Or if you just want to limit what .less files will be compiled, do this:
services.AddWebOptimizer(pipeline =>
{
pipeline.CompileLessFiles("/path/file1.less", "/path/file2.less");
});
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
Differences From twenzel's WebOptimizer.Dotless
- Added an ability to pass css settings to minificator.
- It's now possible to include regular
.css
files into.less
bundles..css
files are not processed byLessEngine
. LessEngine
s imports are reset between each.less
file compilation, when there are multiple.less
files per bundle. It fixes an issue, when multiple files with import statements are located in different directories, but due toLessEngine
's imports caching mechanism,LessEngine
handles them incorrectly, e.g. if two.less
filesdir/a.less
andb.less
imports the sameroot.less
,LessEngine
tries to get content ofroot.less
from incorrect location, when transforningb.less
.- Added a support for abstract
IFileProvider
s, e.g.ManifestEmbeddedFileProvider
. - Use custom
dotless.Core
compiler, which fixes bug inResetImports
method, whech prevents the user to compile multiple.less
files in the same directory, which reference imports the same file. - Drop support for old frameworks. Add support for .NET 7.0 and .NET 8.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 is compatible. 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 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. |
-
net6.0
- LigerShark.WebOptimizer.Core (>= 3.0.348)
- snipervld.dotless.Core (>= 1.6.7.1)
-
net7.0
- LigerShark.WebOptimizer.Core (>= 3.0.348)
- snipervld.dotless.Core (>= 1.6.7.1)
-
net8.0
- LigerShark.WebOptimizer.Core (>= 3.0.348)
- snipervld.dotless.Core (>= 1.6.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.