Referencing other stylesheet files in your .CSS or .LESS source files in Visual Studio 2013

Posted: (EET/GMT+2)

 

If you are building larger web application with Visual Studio and ASP.NET, you might wish to reference styles from other files to make multiple smaller style files instead of a single, large file. This feature is especially useful in .LESS files, but is helpful in plain .CSS files as well.

Normally, Visual Studio 2013 doesn't support LESS language's @import statement, but luckily, you can solve the issue by adding special reference comments. These comments start with the familiar three forward slashes like this:

/// <reference path="bootstrap.less" />

This is exactly the same type of comment that allows you to reference other JavaScript files, or TypeScript definition files from your .TS files.

I noticed that Microsoft has also blogged about this feature here. Looks like it's an undocumented feature. :-)