Gulp web server and file upload

I have a problem with my gulp web server. I have a gulp task:

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

On startup, gulp serveI get the following screen on localhost: 8000:
localhost: 8000

It seems that the web server is serving the root directory of my project and not the tmp folder, it is strange if I click index.html, I am redirected to http://localhost:8000/index.htmlwhich is the correct file ( tmp/index.htmland not /index.html).

I use gulp-webserverfor maintenance and reboot.

What have I done wrong?

Note: uncommenting defaultFile does not help.

+4
source share
3 answers

You can transfer an object to a directory to configure this parameter.

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

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

+3

open . String, ( URL http://my-server:8080/public/).

0

try it

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

Source: https://habr.com/ru/post/1615840/


All Articles