Download this extension from the Marketplace or get the CI build.
An alternative LESS compiler with no setup. Uses the official node.js based LESS compiler under the hood with AutoPrefixer and CSSComb built in.
See the change log for changes and road map.
All .less files will automatically be compiled into a .css file nested under it in Solution Explorer after being enabled on the project.
By default, compilation is off and that's indicated by a watermark at the bottom right corner of any LESS file.
To enable LESS compilation, simply click the watermark and it changes to indicate LESS compilation is "on".
For files that are being ignored, the watermark looks like this:
All .less
files in the following folders are ignored from compilation:
You can stil reference these files from your own .less
files, but they will not be compiled themselves.
Saving the LESS file will then compile into CSS.
The automatic compilation doesn't happen if:
no-compile
is foundThe Output Window shows details about what is being executed to make it easy to troubleshoot any issues.
Note that the the solution (.sln) file is updated to reflect that LESS compilation is enabled. Remember to save the solution when prompted to persits the information.
The solution node in Solution Explorer has a command to compile all .less
files in the enabled projects.
You can set any compiler options as defined on the LESS compiler website inside a comment in the .less
file. The comment is prefixed with lessc
followed by the compiler options.
// lessc --strict-math=on
The default less compiler arguments are:
lessc --relative-urls --autoprefix="> 0%" "<file.css>"
Here are some examples of the code comments to use in the .less
files:
// lessc --source-map
This will produce a .map
file next to the generated .css
file. Be aware that if you specify a file name for the source map like --source-map=file.map
, the file may not be included in the project. Just use the flag without the file name like this --source-map
.
// lessc "../wwwroot/css/file.css"
// lessc --autoprefix="last 2 versions, > 5%"
See Browserlist for description on how to construct the value.
// lessc --csscomb=zen
Available values are zen
, yandex
and csscomb
. Remember to specify --csscomb
after --autoprefix
if both are specified.
By default a .min.css
file is generated, but that can be turned off by a comment containing no-minify
in it. You can combine it with the compiler configuration like so:
// no-minify lessc --relative-urls"
// no-minify lessc --relative-urls --source-map "../wwwroot/css.file.css"
This example doesn't minify the output, enables both relative urls and source maps and redirects the output file to a different directory.
You can specify the compiler options for the solution, the project or for individual folders by placing a file called less.defaults
in any folder next to or above the .less files.
The default file cannot contain information about the output file, but all other options can be set.
Example:
--source-map --relative-urls --strict-math
Note that it isn't prefixed with //
Even though minification isn't technically an option you set on the compiler, you can still opt out of minification like so:
no-minify --source-map --relative-urls --strict-math
Check out the contribution guidelines if you want to contribute to this project.
For cloning and building this project yourself, make sure to install the Extensibility Tools 2015 extension for Visual Studio which enables some features used by this project.