我不能让LiveReload和Grunt一起工作。我用的是咕噜-表。当Grunt正在监视指定的文件时,浏览器中没有重新加载任何内容。所以我会看看:
Running "watch" task
Completed in 0.203s at Thu Nov 21 2013 00:59:59 GMT-0500 (EST) - Waiting...
OK
>> File "views/index.html" changed.
但是浏览器窗口不更新。我使用的是LiveReload 2.0.9。对如何让它运行有什么建议吗?
Gruntfile.js
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
express: {
dev: {
options: {
script: './app.js'
}
}
},
watch: {
tasks: [ 'express:dev' ],
options: {
livereload: true,
nospawn: true
},
files: [
'./views/index.html',
'./preprocessing/css/style.scss'
]
}
});
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [ 'express:dev', 'watch' ]);
};
发布于 2015-01-26 02:15:00
我知道这个问题更老了,但是我从另一个网站得到了这个信息,它似乎可以解决这个问题,因为我也遇到了同样的问题,本质上添加了keepAlive:true to options对象将在这里工作的代码
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
develop: {
server: {
file: 'bin/www'
}
},
watch: {
options: {
nospawn: true,
livereload: reloadPort
},
server: {
files: [
'bin/www',
'app.js',
'routes/*.js'
],
tasks: ['develop', 'delayed-livereload']
},
js: {
files: ['public/js/*.js'],
options: {
livereload: reloadPort,
keepAlive:true
}
},
css: {
files: [
'public/css/*.css'
],
options: {
livereload: reloadPort,
keepAlive:true
}
},
views: {
files: ['views/*.ejs'],
options: {
livereload: reloadPort,
keepAlive:true
}
}
}
});
https://stackoverflow.com/questions/20120412
复制相似问题