1
我正在开发一个简单的节点应用程序,并且遇到这个名为grunt-cli的工具。Grunt - 同时执行和监视应用程序
在介绍到咕噜声之后,我计划将它与我的应用程序一起使用。
Gruntfile.js
module.exports = function(grunt){
grunt.initConfig({
execute: {
target:{
src: ['app.js']
}
},
watch: {
scrpits: {
files: ['app.js'],
tasks: ['execute'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-execute');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['execute', 'watch']);
};
的package.json
{
"name": "exampleapp",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Priyank Thakkar",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"grunt": "^0.4.1"
},
"devDependencies": {
"grunt-contrib-watch": "^1.0.0",
"grunt-execute": "^0.2.2"
}
}
app.js
var express = require('express');
var app = express();
app.set('port', process.env.port || 3005);
app.listen(3005, function(){
console.log('application started at http://localhost:' + app.get('port'));
});
是否正确运行EXECUT随后看手表?不知何故,我觉得终端只停留在执行任务上,它并没有注意到应用程序的变化。
我同意你的建议达成一致。这是两项阻塞任务。所以我不得不通过grunt-concurrent来运行它们。谢谢, –