Reputation: 1564
i am very new to grunt and i wanted to achieve following goal
source:
after processing:
I read somewhere that grunt does that, this is my entire run.js file:
var grunt = require('grunt'),
less = require('less');
grunt.initConfig({
less: {
compileCore: {
options: {
strictMath: true
},
files: [{
expand: true,
src: ['themes/**/file.less'],
ext: '.css',
extDot: 'first'
}]
}
}
});
grunt.registerTask('default', ['less']);
grunt.task.run('default');
it doesnt give any errors but it doesnt work either, how can i make this to work? (again, i have no exprience with grunt whatsoever, yet)
if its possible also to achieve this goal with just command line execution (without runing node.js file) that would be good too ;)
Upvotes: 0
Views: 80
Reputation: 171
you can use grunt.file.expandMapping (https://gruntjs.com/api/grunt.file#grunt.file.expandmapping) to iterate through all the files in a directory and provide options to according to the requirements.
The below code will work according to your requirement.
module.exports = function (grunt) {
grunt.initConfig({
less: {
development: {
files: grunt.file.expandMapping(['themes/**/*.less'], '', {
rename: function (destBase, destPath) {
return destBase + destPath.replace('.less', '.css');
}
})
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['less']);
}
Upvotes: 1