GruntJS livereload不为我工作
我正在尝试在启用livereload选项的情况下配置grunt contrib watch。我正在使用Ubuntu 13.04和Firefox 26.0/Chrome 这是我的Grunfile.jsGruntJS livereload不为我工作,gruntjs,livereload,grunt-contrib-watch,Gruntjs,Livereload,Grunt Contrib Watch,我正在尝试在启用livereload选项的情况下配置grunt contrib watch。我正在使用Ubuntu 13.04和Firefox 26.0/Chrome 这是我的Grunfile.js module.exports = function(grunt) { grunt.initConfig({ watch: { options: { livereload: true },
module.exports = function(grunt) {
grunt.initConfig({
watch: {
options: {
livereload: true
},
html: {
files: ['*.php', '*.html'],
}
}
});
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch']);
};
这是index.html
<html>
<head>
<title>Grunt, Gruntfile.js</title>
</head>
<body>
<h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
<script src="//localhost:35729/example/livereload.js"></script>
</body>
</html>
我通过在终端启动grunt watch并在localhost/example/index.html打开浏览器来测试它,我尝试了Firefox和Chrome
在尝试编辑index.html文件后,我收到了文件index.html更改的通知。在终端上运行grunt watch,但在浏览器上根本没有自动重新加载
我还安装了Firefox和Chrome LiveReload扩展,但它也不起作用。这可能是个愚蠢的问题……但你在浏览器中打开了LiveReload插件吗?我已经打开了一个:我知道这是一个老问题,但看起来不像你在运行服务器。您是否尝试过将grunt contrib connect与手表结合使用?