Tagged CSS

LESS in the .Net World

LESS brought a very different and powerful dynamic to CSS. By introducing few simple features, it has changed the way CSS should be written (generated). The .Net web stack has adopted to utilize LESS and here are some of the tools that bring it to .Net.

SimpLESS

A very simple and headache free solution is SimpLESS. It tracks the LESS files you add and automatically compiles them to CSS and minifies them, based on your preferences.

This solution is independent of the .Net technologies and can work for any valid LESS file. Just add the files you want to track and compile to SimpLESS and it will compile, minify and add some love.

Web Essentials 2012

This Visual Studio 2012 extension is amazing for web developers working in the .Net stack. It brings extensive support for Javascript, HTML, CSS, MarkDown, LESS, CoffeeScript, ZenCoding and TypeScript.

It comes with a preview window and compiles on save. Just like you’d want it to.

Even if you’re not using it to compile LESS, this extension is a must for web developers building with .Net since it brings so many goodies to Visual Studio.

.less{}

Dotless is a .NET port of the Javascript library. There are certain differences still but the library is close to reaching complete compatiblity. Just like most libraries, this too has a handy Nuget package that you can add to your ASP.Net project.

Once added, a reference to dotless.Core will be added to your web project. In the HttpHandlers section of Web.Config a Dotless processor will be added. So that whenever a LESS file is encountered, the processor will take over.

<add type="dotless.Core.LessCssHttpHandler,dotless.Core" validate="false" path="*.LESS" verb="*" />

Futher configuration can be also be added by adding a config handler in the configSections node of Web.Config.

<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler,dotless.Core" />

Then by declaring that section configuration for minification and caching (for example) can be specified. Full documentation is available at the dotless wiki.

<dotless minifyCss="false" cache="true" />

Dotless also is able to work in a client environment and does not contain any server-side handling. This is also available as a Nuget package.