Code Monkey home page Code Monkey logo

gulp-webserver's Introduction

gulp-webserver Build Status

Streaming gulp plugin to run a local webserver with LiveReload

Hint: This is a rewrite of gulp-connect

Install

$ npm install --save-dev gulp-webserver

Usage

The gulp.src('root') parameter is the root directory of the webserver. Multiple directories are possible.

var gulp = require('gulp');
var webserver = require('gulp-webserver');

gulp.task('webserver', function() {
  gulp.src('app')
    .pipe(webserver({
      livereload: true,
      directoryListing: true,
      open: true
    }));
});

Options

Key Type Default Description
host String localhost hostname of the webserver
port Number 8000 port of the webserver
livereload Boolean/Object false whether to use livereload. For advanced options, provide an object. You can use the 'port' property to set a custom live reload port.
directoryListing Boolean/Object false whether to display a directory listing. For advanced options, provide an object. You can use the 'path' property to set a custom path or the 'options' property to set custom serve-index options.
fallback String undefined file to fall back to (relative to webserver root)
open Boolean/Object false open the localhost server in the browser
https Boolean/Object false whether to use https or not. By default, gulp-webserver provides you with a development certificate but you remain free to specify a path for your key and certificate by providing an object like this one: {key: 'path/to/key.pem', cert: 'path/to/cert.pem'}.
middleware Array [] feature coming soon
proxies Array [] a list of proxy objects. Each proxy object can be specified by {source: '/abc', target: 'http://localhost:8080/abc'}.

FAQ

Why can't I reach the server from the network?

Solution: Set 0.0.0.0 as host option.

How can I use html5Mode for my single page app with this plugin?

Solution: Set the index.html of your application as fallback option. For example:

gulp.task('webserver', function() {
  gulp.src('app')
    .pipe(webserver({
      fallback: 'index.html'
    }));
});

License

MIT License

gulp-webserver's People

Contributors

gokulkrishh avatar jimthedev avatar jonathantyates avatar schickling avatar yomguithereal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.