node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

webserver-lite

node-webserver-lite NPM version

Plugin to run a local webserver with LiveReload based on gulp-webserver

Install with npm

npm install webserver-lite

Usage

var WebServer = require('./lib/webserver-lite');
 
var mainWebServer = new WebServer({
    fallback: 'index.html',
    root: path.resolve(__dirname, 'public')
});
 
var adminWebServer = new WebServer({
    fallback: 'index.html',
    proxies: true,
    root: path.resolve(__dirname, 'public/build')
}, 'admin');
 
mainWebServer.start();
adminWebServer.start();

API

WebServer(params)

Server constructor

params

See gulp-webserver options

Extras

livereload: <port>

Type: Number

Shortcut for

livereload: {
    enable: true,
    port: <port>
};
proxies: true

Shortcut for

params.proxies = [{
    source: '/' + params.segment,
    target: 'http://localhost:' + params.port + '/'
}];
segment

Type: String

Path segment. F.e. if segment: 'admin', proxies: true, fallback: 'index.html' server will be use index.html from admin directory if you get localhost:8000/admin/

serverDir
 └──admin
      └──index.html

License

© Oleg Istomin 2015. Released under the MIT license