刚刚在Ubuntu 12.04上安装了最新的Grunt。这是我的gruntfile:
module.exports = function(grunt){
//project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
slides : {
src : ['src/top.html', 'src/bottom.html'],
dest : ['build/index.html']
}
}
});
//enable plugins
grunt.loadNpmTasks('grunt-contrib');
grunt.registerTask('default', ['concat:slides']);
}
这会使build /目录变得很好,但是给出了输出:
运行“concat:slides”(concat)任务警告:无法写入 “build / index.html”文件(错误代码:undefined)。使用--force来 继续。
我尝试在目录上运行chmod 777,因为我认为它可能与权限有关,但这似乎没有改变任何东西。
如何使Grunt写入build / index.html?
答案 0 :(得分:82)
想出来:
//Does not work
dest : ['build/index.html']
作为字符串工作,但不是数组:
//Works
dest : 'build/index.html'
答案 1 :(得分:0)
我将tasks / concat.js更改为接受dest的数组:
// Write the destination file.
// If f.dest is an array take the first element
var dest = ([].concat(f.dest))[0]
grunt.file.write(dest, src);
但后来我决定使用files格式而不是src / dest:
files: { 'dest.js': ['a.js', 'b.js'] }