How to create new compilerconfig.json Web compiler (Extension)?

Liran Patimer picture Liran Patimer · Oct 22, 2015 · Viewed 16.4k times · Source

I have project with a lot of less files, I'm used in Web compiler (developer Mads Kristensen) Extension for visual studio 2015.

my way to create compilerconfig.json is to compile single file and then edit manually the file, to work with all the other less files in the project. I'm sure it's wrong way...

I don't understand, how I can to create new compilerconfig.json file that include all the less files in existing project?

because in this situation when I added new less file the only way to add file is go to compilerconfig.json and add it manually.

we don't have option to create new compilerconfig.json with all the less files in automatically way?

Less Web Compiler

Answer

CodeBob picture CodeBob · Oct 13, 2016

All you need to do after adding a new .less file to your project is right click the new .less file and "Compile File" should be the only option, by selecting that option it will then be added to the compilerconfig.json file. This will not add all the .less files in the project to the config, with a single click, but it will automatically add them with a quick click on each file, and you wont have to be adding them manually.

BEFORE:

[
  {
    "outputFile": "less/site.css",
    "inputFile": "less/site.less"
  }
]

AFTER:

[
  {
    "outputFile": "less/site.css",
    "inputFile": "less/site.less"
  },
  {
    "outputFile": "less/theme.css",
    "inputFile": "less/theme.less"
  }
]

You can also recompile all the files from the Task Runner Explorer window (View -> Other Windows -> Task Runner Explorer). There you should see the compilerconfig.json, below that you will see "LESS", you can "Run" that to compile all, or a select a single file. You can also compile on build.

An alternative method would be to use a gulp file. You can set up a task to get all the less files in your project, without another thought to it after setting it up.