2015-11-07 30 views
3

我試圖使用gulp-live-server自動重啓我的服務器並在我的代碼更改時刷新頁面。gulp-live-server不刷新頁面

這裏是基本設置,我有:

在我server.js:

app.use(require('connect-livereload')()); 

我一飲而盡文件:

gulp.task('server', function() { 
    server = gls('app.js', options); 
    server.start(); 

    // Watch for file changes 
    gulp.watch(['app.js', 'app/**/*.js', 'config/**/*.js', 'components/**/*.jsx'], function() { 
     server.start.bind(server)(); 
     server.notify.bind(server)(); 
    }); 
}); 

我的服務器成功並重新啓動,但瀏覽器不不會刷新。

幫助表示讚賞。

回答

3

嘗試通過調用通知時,傳遞文件:

gulp.task('server', function() { 
    server = gls('app.js', options); 
    server.start(); 

    // Watch for file changes 
    gulp.watch(['app.js', 'app/**/*.js', 'config/**/*.js', 'components/**/*.jsx'], function(file) { 
     server.start.bind(server)(); 
     server.notify.bind(server)(file); 
    }); 
}); 
+1

我無法相信這些命令是無處整個互聯網,但在這裏,在這個不爲人所知的SO職位。它從字面上不會爲我刷新。非常感謝! – Trip

+0

PAGE NOT REFRESHING WITH THIS SCRIPT :( – ShibinRagh