I'm using Grunt for building my web project. I installed grunt-contrib-less
package und added a task to my grunt.initConfig({..});
less : {
options: {
paths: ['js/base']
},
files: {
'js/base/*.css' : 'js/base/*.less'
}
}
when I run the target less via grunt less
, it runs without errors but doesn't compile the less file to a css file.
Running "less:files" (less) task
Done, without errors.
I have installed the lessc package via node, too. Doing lessc <source> <dest>
works fine.
Currently I have pointed with the files option directly to one dir which contains one less file for testing. Even if I write the whole file name into files option, it happens nothing...
Later on I want to scan the whole js directory and compile all new modified *.less files.
I have installed following versions:
grunt-cli v0.1.6
grunt v0.4.0
node v0.8.7
npm 1.1.49
BR, mybecks
The glob pattern
js/base/*.css
does not match any files, therefore there is no destination. Usually, tasks like this expect multiple inputs to combine into a single output. Also, bear in mind thatless
is a multi-task, and puttingfiles
as a child ofless
is not doing what you expect. (it is treating it as a target, not a src/dest map)If you want a 1-1 transform of .less into .css, you can use dynamic expansion. (or you can define each src/dest pair manually, but who wants to do that?)
In your case:
I used Anthonies solution but stil had an error
If I changed the order putting
expand true
as second it gave me the errorwhere "less" was the value of the first item in my list.
I solved it by changing files into an array like this:
I used
"grunt-contrib-less" : "^0.11.0"
This works for me, but modified to reflect this scenario: