繁体   English   中英

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

[英]Browser not reloading with Grunt Livereload

我尝试在更改文件时添加broser的livereload,但未重新加载浏览器,但我不知道为什么,我按此处所述进行操作,并且在调优咕unt声之后打开浏览器,然后在控制台中更改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服务器相同的端口。 在8080上配置了express时grunt-open插件正在使用默认的80端口。

尝试附加与快速配置中相同的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'
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM