我想知道如何查看这里的文件:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-handlebars');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
handlebars: {
compile: {
files: {
"app/handlebars/handlebars-templates.js" : [
"app/handlebars/*.handlebars"
]
}
}
},
watch: {
handlebars: {
files: [
'<%= handlebars.compile.files %>' <== what to put here ?
],
tasks: 'default'
}
}
});
grunt.registerTask('default', 'handlebars');
};我可以放入“app/handlebar/*.handlebar”,但我想写一些动态地采用正确路径的东西
发布于 2013-02-24 07:24:47
配置中的<%= handlebars.compile.files %>指向一个对象。所以手表并不知道你真正想要的是哪些文件。尝试像这样添加/读取配置变量:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
handlebars_path: "app/handlebars/*.handlebars",
handlebars: {
compile: {
files: {
"app/handlebars/handlebars-templates.js" : [
"<%= handlebars_path %>"
]
}
}
},
watch: {
handlebars: {
files: [
"<%= handlebars_path %>"
],
tasks: 'default'
}
}
});或者使用更明确的配置:
handlebars: {
compile: {
src: ['app/handlebars/*.handlebars'],
dest: 'app/handlebars/handlebars-templates.js'
}
}和<%= handlebars.compile.src %>在一起。
https://stackoverflow.com/questions/15022455
复制相似问题