gulp-webserver
gulp-webserver copied to clipboard
It's not working
Hello!
I'm trying to use this plugin, here's my gulp task:
gulp.task('webserver', function() {
gulp.src('./build/')
.pipe(webserver({
directoryListing: true
}))
;
});
When I run this task and open URL in the browser I'm getting list of files from the root of the project, not from the build subdirectory. When I try to navigate to the /build/index.html it show me: Cannot GET /build/index.html.
Please advise. Thanks!
gulp --version
[gulp] CLI version 3.6.2
[gulp] Local version 3.8.10
Update
gulp-connect is working fine with the following code:
gulp.task('webserver', function() {
connect.server({
root: './build',
port: 8888,
fallback: 'index.html'
});
});
+1
+1
This is a duplicate of #26, I'm pretty sure
I wasn't being able to find any working Node web server to use with my single page application, so I've created a simple node server of my own on top of Connect and server-static. Maybe it will help someone: https://github.com/betsol/spa-server. Cheers!
@slavafomin make sure you are using a return statement in _all your streams, I experienced this same thing and going through all my gulp tasks and making sure they returned fix this issue for me
@slavafomin I would start with disabling the directoryListing option. Either by removing, as false by default, or by setting as directoryListing: false. My setup is working here is the config I am using.
// gulpfile.js
var gulp = require('gulp');
var webserver = require('gulp-webserver');
gulp.task('webserver', function() {
gulp.src('public')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
gulp.task('default', ['webserver']);
output from tree:
├── gulpfile.js
├── index.html
├── package.json
└── public
├── css
│ └── style.css
├── img
├── index.html
└── js
:+1: @alnjxn