2017-01-22 124 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,因为您的服务器可能需要重新启动才能使更改生效。