4

I tried setting up the least possible setup for gulp-connect. It shows the following in the terminal window: Server started http://localhost:8080. However it doesn't start Chrome as expected and seen in this video.

var gulp = require('gulp'),
    connect = require('gulp-connect');

var outputDir = "wwwroot";

gulp.task('connect', function() {

 connect.server({
    root: [outputDir],
    open: {browser: 'Google Chrome'}
})});
Kris van der Mast
  • 15,905
  • 7
  • 35
  • 57
  • 1
    They have removed that option as far as I can tell. If you read the youtube comments, you will see someone asking the same thing. Not sure if they ever got it to work. The plugin hides connect's events so this is a tough case. You can always write another task to open the browser and have the `connect` task as a dependency. – Lim H. Sep 05 '15 at 19:04

3 Answers3

6

I did some research and didn't found any options for open in gulp-connect. So I'm going to assume that he used an older version of the module witch supported that feature.

Option 1:

To solve your problem you can use gulp-connect-multi, a forked version of gulp-connect witch includes browser opening functionality.

Option 2:

If you still want to use gulp-connect I recommend using a module called gulp-open (or even just open) that opens files and urls in the browser.

Option 3:

Search for more or create you own.

Best of Luck.

0

I have faced the same issue with gulp-connect. Then I have fixed this issue by installing another package named gulp-connect-multi

npm install --save-dev gulp-connect-multi

var connect = require("gulp-connect-multi")();

gulp.task('html', function () {
    gulp.src(config.paths.html).pipe(gulp.dest(config.paths.dist)).pipe(connect.reload());

});

Hope this helps

Code-EZ
  • 6,514
  • 11
  • 44
  • 72
-1

To connect to my browser sync, I navigate to my gulp folder in cmd (the one that has node-mudules, in your project folder) and just type in "Gulp". It automatically opens my project in the browser. Hope this helps.

Daniel Sushik
  • 78
  • 1
  • 12