4
votes

Visual Studio generates an empty .css file when I compile a .less file. I have this problem in both Visual Studio 2015 and 2017. The file is being compiled because I just wrote something and I can see that it removes the text and overrides it with the empty content.

There are also no error during the compilation. I have Web Essentials and Web Compiler installed (the latest versions because it's updates automatically). I've checked for validation on external online less validators with no errors.

I also tried creating a new .less file and compile it, I get the same empty generated css file.

1
Does it compile from the command line? lessc yourfile.less > output.css - Demnogonis
@Demnogonis I opened the Visual Studio 2017 developer command prompt and try just to enter "lessc" command but it's not recognized as a command. - Idan Shechter
Ok so VS seems to bring its own less compiler. I recommend installing node.js and then installing less via npm (guide from the docs). Then you'll have the latest version of less available. I'm guessing that you can configure Visual Studio to use that instead. - Demnogonis
@Demnogonis I installed the node.js and less compiter and created a batch file to compile. Is there any easier way to achieve it or automate the compilation each time I save a file in visual studio? - Idan Shechter
I don't know about visual studio since I'm mostly working with sublime text. I'm using grunt for my buildchains. But this is also an external tool. But I'm guessing there is a way to tell visual studio to invoke an external command when a file is saved - Demnogonis

1 Answers

1
votes

According to https://github.com/madskristensen/WebCompiler/issues/299 you have to build/rebuild explicitly or right-click on the less file and build. It doesn't happen automatically on save any more.