Gujarat Santana Gujarat Santana - 7 months ago 104
Javascript Question

gulp 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.

Answer

Use the port option.

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

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

Comments