2015-06-03 64 views
0

我试图在更改我的文件时添加broser livereload,但浏览器不能重新加载,我无法得到原因,我做的全部都像描述的here,并且浏览器在我tun grunt时打开,然后当改变index.html,在控制台得到浏览器不能重新加载Grunt Livereload

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' 
    ]); 
}; 
+0

请附上相关你的grunt文件的部分,所以我们可以看到你是如何试图完成这一点。 – Lix

+0

您在index.html中没有使用AppCache清单吗?如果您使用脱机缓存,浏览器将不会重新加载。上周我有这个问题。 –

+0

@jonnyknowsbest,不,我没有使用缓存... – nowiko

回答

1

也许原因是您咕噜开插件不与相同的端口配置表达服务器。该咕噜开插件使用的是默认端口80,而表达是在8080

配置尝试附加相同的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' 
    } 
} 
+0

越来越'无法GET/megapolis/index.html' – nowiko

+0

你正在'var \\ www \\ megapolis'或'var \\ www'内运行'grunt server' ?而'index.html'文件驻留在'var \\ www \\ megapolis'文件夹中? – dreyescat

+0

我在megapolis文件夹中运行命令,并且index.html放在同一个目录中 – nowiko

相关问题