我在node.js中有一个Web应用程序,我想从nodemon开始,因此每次主脚本更改时,该Webapp都可以重新启动。
同时,我有我的coffeescript文件,每次它们更改时都需要重新编译。
我已经设置了grunt-contrib-watch任务,以仅监听app/frontend/*.coffee
文件,以调度咖啡解析器。
但是,这似乎没有发生变化,因为nodemon任务也在监听。
我在nodemon忽略中设置app/frontend/
文件夹。
我还设置了nodemon并观看了并发。
尽管如此,每次我编辑咖啡脚本时,都不会执行咖啡任务。
这是我的Gruntfile
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
concurrent: {
dev: [
'nodemon',
'watch'
],
options: {
logConcurrentOutput: true
}
},
coffee: {
compile: {
files: {
'app/public/app.js': ['app/frontend/*.coffee']
}
}
},
nodemon: {
dev: {
script: 'app/index.js',
options: {
ignore: ['app/frontend/**', 'app/public/**']
}
}
},
watch: {
scripts: {
files: 'app/frontend/*.coffee',
tasks: ['coffee'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-nodemon');
// Default task(s).
grunt.registerTask('default', ['coffee', 'nodemon', 'watch']);
};
最佳答案
您的Gruntfile指示Grunt作为默认任务按顺序运行nodemon
和watch
(因此,watch
永远不会运行,因为nodemon
永远不会完成)。
您需要在最后一行中明确包含concurrent
任务:
grunt.registerTask('default', ['coffee', 'concurrent']);