Grunt 0.4 less任务:如何不连接目标文件 [英] Grunt 0.4 less task : How to not concatenate destination files
问题描述
我想从相应的.less文件生成.css部分文件
我使用npm提供的最新版本,grunt@0.4.0,grunt-contrib -less@0.5.0
在Grunt版本0.4之前,我可以简单地指定模式:
htdocs / less / *。less
作为源代码
htdocs / css / *。css code>作为目的地
以及文件夹 htdocs / less
中的所有文件都将生成文件夹 htdocs / css
从v0.4开始,目标模式不再起作用, code> htdocs / less 被连接成一个名为 * .css
如何配置它生成所有文件的任务,而不是将它们连接成一个文件。
我不想单独列出文件。
在Grunt文档中找不到答案 http://gruntjs.com/configuring-tasks#files does $
谢谢。
我的Gruntfile.js(摘录):
module.exports = function(grunt){
grunt.initConfig({
less:{
development:{
files:{
htdocs / css / *。css:htdocs / less / * .less
}
}
},
});
};
您需要阅读动态构建文件对象部分。
这将是您当前配置的直接翻译:
module.exports = function(grunt ){
grunt.initConfig({
less:{
development:{
files:[{
expand:true,//启用动态扩展
cwd:'htdocs / less',// Src匹配相对于此路径
src:['* .less'],//匹配的实际模式
dest:'
ext:'.css',// Dest文件路径将有这个扩展名
}]
}
},
});
};
I want to generate .css partial files from the corresponding .less files
I use the latest versions available from npm, grunt@0.4.0, grunt-contrib-less@0.5.0
Prior to Grunt version 0.4 I could simply specify the pattern:
htdocs/less/*.less
as source
htdocs/css/*.css
as destination
and all the files from the folder htdocs/less
would be generated into the folder htdocs/css
Since v0.4 the destination pattern does no longer work, all files from the folder htdocs/less
are concatenated into one file named *.css
How can I configure the task that it generates all files instead concatenating them into one file.
I do not want list the files individually.
Couldn't find an answer in the Grunt documentation http://gruntjs.com/configuring-tasks#files does
Thank You.
My Gruntfile.js (extract):
module.exports = function (grunt) {
grunt.initConfig({
less: {
development: {
files: {
"htdocs/css/*.css": "htdocs/less/*.less"
}
}
},
});
};
You'd want to read the Building the files object dynamically section in the docs.
This would be a direct translation from your current config:
module.exports = function (grunt) {
grunt.initConfig({
less: {
development: {
files: [{
expand: true, // Enable dynamic expansion.
cwd: 'htdocs/less', // Src matches are relative to this path.
src: ['*.less'], // Actual pattern(s) to match.
dest: 'htdocs/css', // Destination path prefix.
ext: '.css', // Dest filepaths will have this extension.
}]
}
},
});
};
这篇关于Grunt 0.4 less任务:如何不连接目标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!