10

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

1
  • Didn't you forget the image? Oct 22, 2015 at 11:48

1 Answer 1

9

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.

3
  • Still works for older MVC Projects in Visual Studio 2019. This should be the accepted answer
    – Bluesight
    Jan 30, 2020 at 10:33
  • Task Runner Explorer showed me that there was an error in my .less files which werent being output during build. Very useful, thanks.
    – Jimbo
    May 1, 2020 at 10:20
  • This doesn't answer the question. How can we add one parent file into the compiler config file, that is already referencing multiple scss files into itself?
    – klewis
    Feb 9, 2021 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.