【发布时间】:2013-02-20 05:24:27
【问题描述】:
我觉得我错过了什么。
这是我想要实现的目标:
有一个执行我的 server.js 并并行运行 watch 任务的 grunt 任务。在我看来,这正是 grunt 设计的任务之一,但我无法实现这种配置。
除其他外,我读过这个: Running Node app through Grunt 但我还是做不到。
这是我的 Gruntfile.js :
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
scripts: {
files: ['*.js'],
tasks: ['start'],
options: {
nospawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('start', function() {
grunt.util.spawn({
cmd: 'node',
args: ['server.js']
});
grunt.task.run('watch');
});
grunt.registerTask('default', 'start');
};
我有"grunt-contrib-watch": "~0.3.1",它的版本应该比前面提到的帖子中的grunt-contrib-watch@0.3.0 更高。
如果您能帮助我实现正确的配置,我将不胜感激。但更一般地说,我不明白为什么没有官方的 grunt-contrib-nodemon-like 包和任务,因为我觉得这将是使用 grunt 的另一个重要原因(我真的很喜欢它作为一个工具!)
谢谢
【问题讨论】:
标签: node.js gruntjs watch spawn