I used the following as pre-build event in Visual Studio 2013 to compile Bootstrap 3.0 with recess according to this answer and it worked
recess "$(ProjectDir)Content\bootstrap\bootstrap.less" --compress > "$(ProjectDir)Content\bootstrap-compiled.css"
Now this doesn't work for Bootstrap 3.1.1 and they say Grunt will do it. I've tried:
grunt-contrib-less "$(ProjectDir)Content\bootstrap\bootstrap.less" --compress > "$(ProjectDir)Content\bootstrap-compiled.css"
But can't get it to work. Any ideas how to get Grunt to work with VS 2013.
Note: I've Installed Node.js and recess earlier, then > npm install grunt-contrib-less then to be sure >npm update grunt-contrib-less.
I've got this working in a slightly different way:
npm install -g grunt-cli
)call grunt less
to your pre-build event (if you don't specify CALL, then the process doesn't return after grunt)You can add different targets to the development and production build processes if you like. You can also set up more targets for other tasks - I have one so I can run
grunt watch
to automatically recompile my CSS if I edit less files.Step-by-step guide to converting the VS2013 sample project to use less and Grunt:
Remove bootstrap and install bootstrap less:
Ensure grunt-cli is installed globally:
Create a package.json file:
Create a file in your project called
Gruntfile.js
with the following contents:Edit your Visual Studio pre-build event to include:
(
--no-color
removes some of the control characters from the Visual Studio build output)