Gruntjs Grunt Livereload通过Grunt contrib手表不刷新浏览器
我对Grunt很陌生,我正试图通过Grunt contrib watch插件启用livereload,但我的浏览器并不刷新。这是我当前的Gruntfile.js:Gruntjs Grunt Livereload通过Grunt contrib手表不刷新浏览器,gruntjs,grunt-contrib-watch,Gruntjs,Grunt Contrib Watch,我对Grunt很陌生,我正试图通过Grunt contrib watch插件启用livereload,但我的浏览器并不刷新。这是我当前的Gruntfile.js: module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { options: { liv
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
livereload: true
},
files: ['*.html']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Grunt example</title>
</head>
<body>
<h1>Grunt example</h1>
<p>A paragraph</p>
<script src="//localhost:35729/livereload.js"></script>
</body>
</html>
我的index.html文件与Gruntfile.js位于同一文件夹中:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
livereload: true
},
files: ['*.html']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Grunt example</title>
</head>
<body>
<h1>Grunt example</h1>
<p>A paragraph</p>
<script src="//localhost:35729/livereload.js"></script>
</body>
</html>
咕哝的例子
咕哝的例子
段落
因此,我执行“grunt watch”,在更改index.html文件后,我从控制台收到以下消息:
文件“index.html”已更改。
在0.000秒内完成,时间为
但我的浏览器并不令人耳目一新。我遗漏了什么吗?是否有错误?将脚本块更改为:
<script src="//localhost:35729/livereload.js"></script>
致:
你应该把它修好