How to configure port in browser-sync

后端 未结 1 502
悲&欢浪女
悲&欢浪女 2021-02-05 19:13

I have a gulp task running with browser-sync,by default its running on port 3000 of node.js server.I want to change the default port to any other port

相关标签:
1条回答
  • 2021-02-05 19:57

    Answer based on the documentation links (link1, link2).

    You are using browser-sync version 2.0+, they have a different recommended syntax. Using that syntax your code could be like this:

    // require the module as normal
    var bs = require("browser-sync").create();
    
    ....
    
    gulp.task('serve', [], function() {
      // .init starts the server
      bs.init({
        server: "./app",
        port: 3010
      });
    });
    

    You specify required port directly in configuration object.

    0 讨论(0)
提交回复
热议问题