0
我有一个文件数组中的多个对象的问题。我有两组需要通过uglify
运行的文件,一个是需要压缩的单个文件,另一个是一组文件。问题是,任务总是说没有定义源文件。 src
和dest
是相同的,因为这些文件是就地压缩的 - 这在以前工作,问题出现在我引入模板时。我设置了一个简单的测试任务来验证。这里是任务配置:咕噜源文件是空的
buildDir: "bin",
build: {
test: {
files: [
{
src: ["<%= buildDir %>/js/vendor.js"],
dest: "<%= buildDir %>/js/vendor.js"
},
{
expand: true,
src: ["<%= buildDir %>/js/**/main.js"],
dest: ["<%= buildDir %>/js/**/main.js"]
}
]
}
}
这是我的简单测试任务:
grunt.registerMultiTask('build', function() {
console.log(this.files); // Shows first object only
console.log(this.filesSrc); // Blank
this.files.forEach(function(file) {
grunt.log.writeln("Src: " + file.src); // Blank
grunt.log.writeln("Orig: " + file.orig.src); // bin/js/vendor.js
file.src.forEach(function(filePath) {
grunt.log.write("Checking: " + filePath);
if (!grunt.file.exists(filePath)) {
grunt.log.warn("Not found!");
} else {
grunt.log.warn("File found!");
}
});
grunt.log.writeln("Dest: " + file.dest);
});
return false;
});
文件数组中的第二个目的是根本不存在的所有任务中,和第一个有空白src
财产。