Grunt在每个目录中编译所有.less到.css [英] Grunt compile all .less to .css in each directory
问题描述
文件夹结构:
/ common / modules / {module-name} /style.less
我需要将所有style.less文件转换为同一目录中的style.css文件。例如:
/common/modules/clock/style.less
需要被编译为 /common/modules/clock/style.css
我不想单独将每个模块添加到我的grunt文件,有没有办法做到这一点动态? 解决方案
http://gruntjs.com/configuring-tasks#globbing-patterns
您可以定义以下任务:
grunt.initConfig({
less:{
compileCore :{
options:{
strictMath:true
},
files:[{
expand:true,
src:['/ common / modules /**/style.less'],
ext:'.css',
extDot:'first'
}]
}
}
});
So I have setup my site to use modules, in which each module has it's own .less file which needs to be compiled into .css.
Folder Structure:
/common/modules/{module-name}/style.less
I need all the style.less files to be converted into style.css files in the same directory. For example:
/common/modules/clock/style.less
would need to be compiled to /common/modules/clock/style.css
I don't want to have to add each of the modules individually to my grunt file, is there a way to do this dynamically?
See also: http://gruntjs.com/configuring-tasks#globbing-patterns
You can define the following task:
grunt.initConfig({
less: {
compileCore: {
options: {
strictMath: true
},
files: [{
expand: true,
src: ['/common/modules/**/style.less'],
ext: '.css',
extDot: 'first'
}]
}
}
});
这篇关于Grunt在每个目录中编译所有.less到.css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!