4

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.

Liron Harel
  • 10,819
  • 26
  • 118
  • 217
  • Does it compile from the command line? `lessc yourfile.less > output.css` – Demnogonis Jun 09 '17 at 08:02
  • @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. – Liron Harel Jun 11 '17 at 11:05
  • 1
    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)](http://lesscss.org/usage/#command-line-usage). Then you'll have the latest version of less available. I'm guessing that you can configure Visual Studio to use that instead. – Demnogonis Jun 12 '17 at 07:39
  • @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? – Liron Harel Jun 15 '17 at 11:33
  • 1
    I don't know about visual studio since I'm mostly working with sublime text. I'm using [grunt](https://gruntjs.com/) 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 Jun 15 '17 at 12:58

1 Answers1

1

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.

mikep
  • 3,841
  • 8
  • 21