ASP.NET MVC Bundling of Bootstrap Less Source


updated 5 years ago

Our team is utilizing bootstrap for our MVC application. We would like to be able to update the variables.less file and have the entire "theme" of the website updated.

The typical methods are:

  • Utilize a tool (Chirpy in Visual Studio) to automatically output css anytime the less file is updated
  • Transform the less on the server side

I prefer the second approach since:

  • It doesn't depend on everyone having the same tool setup
  • You don't have worry about versioning of the code generated files

The most popular library dotless utilizes HttpHandlers to translate the less to css on the server side. This requires extra configuration in the web.config.

However, the latest version of ASP.NET MVC, version 4, has support for bundling and minification. It also supports transforms.

The article shows a few simple lines of code to add a transform for less files.