【发布时间】:2026-01-24 04:40:01
【问题描述】:
所以我遇到的问题是 grunt-nodemon 和 watch 并发运行,除了浏览器 livereload 之外一切正常。
如果我在没有并发的情况下运行 watch,一切正常,但 nodewatch 却不行。
【问题讨论】:
所以我遇到的问题是 grunt-nodemon 和 watch 并发运行,除了浏览器 livereload 之外一切正常。
如果我在没有并发的情况下运行 watch,一切正常,但 nodewatch 却不行。
【问题讨论】:
经过几个小时的挖掘,我确实解决了这个问题。我通过为 nodemon 生成子进程来解决它。如果您有任何问题,我很乐意为您提供帮助。
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
// Running nodejs in a different process and displaying output on the main console
var nodemon = grunt.util.spawn({
cmd: 'grunt',
grunt: true,
args: 'nodemon'
});
nodemon.stdout.pipe(process.stdout);
nodemon.stderr.pipe(process.stderr);
grunt.task.run([
'clean:server',
'bowerInstall',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch',
]);
});
【讨论】: