gulp webserver和livereload

vli*_*o20 7 javascript node.js gulp

我的gulp网络服务器有问题.我有这个gulp任务:

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

运行时,gulp serve我在localhost:8000上获得以下屏幕:
本地主机:8000

看起来网络服务器正在服务于我的项目的根目录而不是tmp文件夹,奇怪的是如果我点击index.html我被重定向到http://localhost:8000/index.html哪个是正确的文件(tmp/index.html而不是/index.html).

我正在使用gulp-webserver服务和重新加载.

我做错了什么?

注意:取消注释defaultFile没有帮助.

gki*_*ely 5

您可以将一个对象传递到directoryListing中以调整此设置。

.pipe(webserver({
  directoryListing: {
    enable: true,
    path: 'tmp'
  }
}));
Run Code Online (Sandbox Code Playgroud)

详细信息:https : //github.com/schickling/gulp-webserver#options