浏览器未使用 Grunt Livereload 重新加载

Browser not reloading with Grunt Livereload

我试图在更改我的文件时添加 broser 的 livereload,但浏览器没有重新加载,我不明白为什么,我按照描述的方式进行操作 here,当我 tun grunt 时浏览器打开,然后当更改时index.html,在控制台中获取

Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 11:45:24 GMT+0300 (EEST) -  Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 11:54:11 GMT+0300 (EEST) - Waiting...
>> File "index.html" changed.
Completed in 0.000s at Wed Jun 03 2015 12:01:30 GMT+0300 (EEST) -     Waiting...

但是浏览器没有重新加载,我做错了什么?也许我想念什么?我试图用谷歌搜索问题,但没有得到任何有用的结果...如果您需要我的 Gruntfile 或任何东西,请告诉我。谢谢!

这是我的 Gruntfile.js :

module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
// Grunt express - our webserver
// https://github.com/blai/grunt-express
express: {
    all: {
        options: {
            bases: ['var\www\megapolis'],
            port: 8080,
            hostname: "localhost",
            livereload: true
        }
    }
},
// grunt-watch will monitor the projects files
// https://github.com/gruntjs/grunt-contrib-watch
watch: {
    all: {
            files: '**/*.html',
            options: {
                livereload: true
        }
    }
},
// grunt-open will open your browser at the project's URL
// https://www.npmjs.org/package/grunt-open
open: {
    all: {
        path: 'http://localhost/megapolis/index.html'
    }
}
});
// Creates the `server` task
grunt.registerTask('server', [
    'express',
    'open',
    'watch'
    ]);
};

可能是因为您的 grunt-open 插件没有配置与 express 服务器相同的端口。 grunt-open 插件使用默认的 80 端口,而 express 在 8080 上配置。

尝试附加与 express 配置中相同的 8080 端口:

// grunt-open will open your browser at the project's URL
// https://www.npmjs.org/package/grunt-open
open: {
    all: {
        path: 'http://localhost:8080/megapolis/index.html'
    }
}