2017-01-22 126 views
0

我重新閱讀grunt觀看頁面上的指南,並在其他地方跟着3個不同的例子,但我不能讓它自動刷新我的網頁時,一個html或js文件被修改...我的意思是我收到「文件更改:意見/ entryw.html」的消息,但這樣它正在監視但沒有自動重載/自動刷新瀏覽器同步不自動刷新

我的服務器的跡象在端口9000

運行這是我的Gruntfile。 js的樣子:

module.exports = function (grunt) { 


    // --------------------------------------------------------------------------------------------- // 
    // Configuration 
    // --------------------------------------------------------------------------------------------- // 
    grunt.initConfig({ 
     browserSync: { 
      bsFiles: { 
       src : [ 
        'forbiddenDirectory/*.js', 
        'views/*.html' 
       ] 
      }, 
      /*options: { 
       server: { 
        baseDir: "./" 
       } 
      }*/ 
      options: { 
       proxy: "localhost:3000", 
       open: false 
      } 
     } 
    }); 


    // --------------------------------------------------------------------------------------------- // 
    // Load plugins 
    // --------------------------------------------------------------------------------------------- // 
    grunt.loadNpmTasks('grunt-browser-sync'); 



    // --------------------------------------------------------------------------------------------- // 
    // register tasks 
    // --------------------------------------------------------------------------------------------- // 
    grunt.registerTask('default', ['browserSync']); 

    //grunt.registerTask('all', ['default']) // each index in array is the name of registered tasks above 

} 

回答

0

我覺得proxy option應該指向你的服務器的端口9000,如下所示:

options: { 
    proxy: 'http://localhost:9000' 
} 

您可以通過瀏覽器同步在http://localhost:3000然後訪問應用程序,這將通過代理服務端口9000的實際服務器。

YMMV,因爲您的服務器可能需要重新啓動才能使更改生效。