我目前正在使用Grunt和livereload,但由于某种原因,在服务器文件更改时它不再重新启动服务器。它正在观察服务器文件,当文件发生变化时我收到Reload server/some_dir/some_file.js
消息,但这似乎不够。
watch: {
jade: {
files: [
'<%= yeoman.server %>/**/*.jade',
'<%= yeoman.app %>/**/*.jade'
],
tasks: ['jade']
},
compass: {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass']
},
livereload: {
options: { livereload: true },
files: [
'{.tmp,<%= yeoman.server %>}/**/*.js',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
'{.tmp,<%= yeoman.app %>}/**/*.html',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['livereload']
},
server: {
files: [ './server/**/*' ],
tasks: [ 'express:dev', 'livereload-start' ]
}
}
grunt.registerTask('server', [
'clean:server',
'jade',
'compass:server',
'express:dev',
'livereload-start',
'connect:livereload',
'watch' // if I replace this with 'watch:server' the server does restart properly, but html/css updates are obviously gone
]);
答案 0 :(得分:1)
我不确定你使用的这些软件包的版本,但是livereload不再是(并且已经有几个月没有)任务本身。它现在应作为监视https://github.com/gruntjs/grunt-contrib-watch#optionslivereload的选项运行。
以下是一个例子:
watch: {
assets: {
files: ['assets/**/*'],
tasks: ['copy:assets']
},
scripts: {
files: ['scripts/source/*.js'],
options: {
livereload: true
}
}
}
grunt.registerTask('default', ['watch']);
答案 1 :(得分:0)
更改
server: {
files: [ './server/**/*' ],
tasks: [ 'express:dev', 'livereload-start' ]
}
到
server: {
files: [ './server/**/*' ],
tasks: [ 'express:dev', 'livereload' ]
}
不确定最近的变化会导致这种情况发生。根据git,从项目开始就使用了前片段。