gulp-webserver icon indicating copy to clipboard operation
gulp-webserver copied to clipboard

It's not working

Open slavafomin opened this issue 11 years ago • 7 comments
trafficstars

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'
    });
});

slavafomin avatar Nov 15 '14 00:11 slavafomin

+1

paulsonnentag avatar Dec 28 '14 14:12 paulsonnentag

+1

vmadman avatar Dec 30 '14 06:12 vmadman

This is a duplicate of #26, I'm pretty sure

vmadman avatar Dec 30 '14 06:12 vmadman

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 avatar Mar 22 '15 19:03 slavafomin

@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

ghost avatar Aug 05 '15 00:08 ghost

@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

alnjxn avatar Dec 11 '15 16:12 alnjxn

:+1: @alnjxn

beeisabelm avatar Mar 08 '16 15:03 beeisabelm