Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gulp-connect and gulp-open file not load through the server

Tags:

gulp-connect

I'am trying to run a web server and open an HTML file via gulp-connect and gulp-open.

The server is running, the html is opened correctly but not through the server but as a file from the HDD.

On the URL address bar I can see: "file:///Users/...." instead of "http://localhost:9000/"

Does anyone know what could be the issue ?

Thanks for your help

"use strict";

var gulp = require('gulp');
var gulpConnect = require('gulp-connect'); // run a local dev server
var gulpOpen = require('gulp-open'); // open a URL in the browser

var config ={
    port:'9000',
    baseDevUrl:'http://localhost',
    paths: {
        html: './src/*.html',
        dist:'./dist'
    }

};
// start a local development server

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

    gulpConnect.server({
        root:['dist'],
        port: config.port,
        base: config.baseDevUrl,
        livereload:true
    });

});

gulp.task('open',['connect'],function(){
       gulp.src('dist/index.html')
           .pipe(gulpOpen('',{ url: config.baseDevUrl +':'+ config.port +'/', app:'google chrome'}));
});

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

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

    gulp.watch(config.paths.html,['html']);


});


gulp.task('default',['html','open','watch']); 
like image 218
Samo Avatar asked Sep 09 '15 23:09

Samo


1 Answers

OK here is how you open things:

  gulp.src('./index.html').pipe(gulpOpen({uri: 'http://localhost:8888', app: 'Google Chrome'}));

You've got an extra first parameter in gulpOpen and url should be uri

Good luck!

like image 95
Devin McQueeney Avatar answered Oct 27 '22 06:10

Devin McQueeney