【发布时间】:2017-03-18 06:22:38
【问题描述】:
我对 Grunt 很陌生,我正在尝试通过 grunt-contrib-watch 插件启用 livereload,但我的浏览器没有刷新。这是我当前的 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');
};
我在与 Gruntfile.js 相同的文件夹中有一个 index.html 文件:
<!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 秒内完成...
但是我的浏览器没有刷新。我错过了什么吗?有什么错误吗?
【问题讨论】:
标签: gruntjs grunt-contrib-watch