Tuesday, January 2, 2018

Setup dotLess CSS In ASP.NET MVC Project (Minify js/cs file)

Improve performance for dotLess files in MVC projectBundles are an easy way to merge and minify resources in your application (such as JavaScript files and CSS stylesheets). Using “System.Web.Optimization.Less” plugin, you can improve site performance in a better way.

So go back to Package Manager Console and install the below plugin:

PM> Install-Package System.Web.Optimization.Less

And add your bundle to the appropriate location within BundleConfig.cs,
  1. public class BundleConfig  
  2. {  
  3.     public static void RegisterBundles(BundleCollection bundles)  
  4.     {  
  5.         // NOTE: existing bundles are here  
  6.   
  7.         bundles.Add(new LessBundle("~/Content/less").Include("~/Content/*.less"));  
  8.     }  
  9. }  
So, this LessBundle gives you the facility to combine and minify files while running the application in <compilation debug="false" /> mode, and it takes care of transforming LESS code into CSS. It does not require updating the layout every time you add a new file to the project.

No comments:

Post a Comment