2015-06-03 63 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

相關問題