Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gulp webserver and livereload

I have a problem with my gulp webserver. I have this gulp task:

gulp.task('serve', ['watch'], () => {
  gulp.src('tmp')
    .pipe(webserver({
      livereload: true,
      directoryListing: true,
      open: true,
      //defaultFile: 'index.html'
    }));
});

When running gulp serve I am getting the following screen on localhost:8000:
localhost:8000

It seems like that the webserver is serving the root directory of my project and not tmp folder, the odd thing is if I click the index.html I am redirected to http://localhost:8000/index.html which is the correct file (tmp/index.html and not /index.html).

I am using gulp-webserver for serving and live reload.

What did I do wrong?

Note: uncommenting the defaultFile doesn't help.

like image 804
vlio20 Avatar asked Nov 13 '15 23:11

vlio20


2 Answers

You can pass an object into directoryListing to adjust this setting.

.pipe(webserver({
  directoryListing: {
    enable: true,
    path: 'tmp'
  }
}));

Details: https://github.com/schickling/gulp-webserver#options

like image 162
gkiely Avatar answered Sep 19 '22 16:09

gkiely


open can be also a string.By providing a String you can specify the path to open (for complete path, use the complete url http://my-server:8080/public/) .

like image 43
Juri Avatar answered Sep 21 '22 16:09

Juri