Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser-sync serve command with different port

I want to try using gulp and I've made a simple project similar to this example
what I want to do is to serve the project using different port, I've tried to follow this costum-port example

and my gulpfile.js looks like this :

var gulp = require('gulp');
var browserSync = require('browser-sync');
var livereload = require('gulp-livereload');
var reload = browserSync.reload;

// watch files for changes and reload
gulp.task('serve', function() {
  livereload.listen(1234);

  browserSync({
    server: {
      baseDir: 'app',
    }
  });

  gulp.watch(['*.html', 'styles/**/*.css', 'scripts/**/*.js'], {cwd: 'app'}, reload);
});

I also try to add port in server :{porrt : 9999, baseDir:'app'} but the result end up with the default port which is 3000.

Is it possible to change the port? Thanks.

like image 887
Gujarat Santana Avatar asked Apr 30 '16 03:04

Gujarat Santana


People also ask

How do I change browser browser sync?

In Sublime Text 3 go to Preferences -> Browse Packages... Open 'Browser Sync' folder and edit the browser property in browser_sync_launch. js file. Save this answer.

How does Browsersync proxy work?

How Does BrowserSync Work? BrowserSync starts a small web server. If you're already using a local web server or need to connect to a live website, you can start BrowserSync as a proxy server. It injects small script into every page which communicates with the server via WebSockets.

How do I use Vscode browser sync?

BrowerSync VSCODE Starts a browserSync Static server with watch mode at :3000 by default. The UI for browsersync is available at :3001 . Right click on the folder from your VSCODE explorer menu. And click on BrowerSync Start .


1 Answers

Use the port option.

browserSync({
    port: 9999,
    server: {
      baseDir: 'app',
    }
  });

port is a direct option of BrowerSync, not a sub-option under server option.

like image 152
qtuan Avatar answered Oct 05 '22 10:10

qtuan