我有以下咕噜任务(简体):延迟计算咕噜任务选项
rev: {
files: {
src: ['dist/**/*.{js,css}']
}
},
processhtml: {
dev: {
options: {
data: {
appJs: grunt.file.expand('dist/**/*.js')
}
},
files: {
'dist/index.html': 'app/index.html'
}
}
}
的grunt-rev
任务首先运行,这需要定期JS,并预置的哈希码的文件名。然后运行grunt-processhtml
任务,对于这种情况我想获取由grunt-rev
生成的所有JS文件名,并将它们作为自定义数据传递。
这段代码的问题是,它似乎在首次执行gruntfile不是processhtml
任务运行时急切地执行grunt.file.expand
方法,并且,所以这意味着我得到的文件不同的列表,从grunt.file.expand
比我预期,因为它不考虑grunt-rev
任务的结果。
当任务实际运行时,是否有办法强制延迟评估值?
可能会有帮助:http://stackoverflow.com/questions/15735485/how-to-make-grunt-wait-for-a-task-to-finish -before-running-another –
您可能会觉得这很有用:http://stackoverflow.com/questions/28847471/grunt-how-to-build-the-files-object-dynamically/29244332#29244332 – almeidap