A static web-server for productive front-end development.
A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**.
**Requires node v4.0.0 or higher**.
## Synopsis
## Synopsis
From the folder you wish to serve, run:
Serve a directory on the default port:
```sh
```sh
$ ws
$ ws
serving at http://localhost:8000
serving at http://localhost:8000
```
```
If you wish to serve a different directory, run:
Blacklist certain paths, for example config files:
```sh
```sh
$ ws -d ~/mysite/
serving /Users/Lloyd/mysite at http://localhost:8000
$ ws --forbid .json .yml
serving at http://localhost:8000
```
```
If you wish to override the default port (8000), use `--port` or `-p`:
Reduce bandwidth with gzip compression:
```sh
```sh
$ ws --port 9000
serving at http://localhost:9000
$ ws --compress
```
```
To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
Specify a Single Page Application:
```sh
```sh
$ ws --compress
$ ws --spa index.html
```
```
## Install
## Install
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
### Globally
```sh
```sh
$ npm install -g local-web-server
$ npm install -g local-web-server
```
```
### Bundled with your project
## Distribute with your project
```sh
```sh
$ npm install local-web-server --save-dev
$ npm install local-web-server --save-dev
```
```
@ -71,24 +69,6 @@ $ npm install
$ npm start
$ npm start
```
```
### Logging
Passing a value to `--log-format` will write an access log to `stdout`.
Either use a built-in [morgan](https://github.com/expressjs/morgan) logger preset:
```sh
$ ws --log-format short
```
Or a custom [morgan](https://github.com/expressjs/morgan) log format:
```sh
$ ws -f ':method -> :url'
```
Or silence:
```sh
$ ws -f none
```
## Storing default options
## Storing default options
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
```json
```json
@ -139,7 +119,7 @@ You can set additional mime-type/extension mappings, or override the defaults by
## Log Visualisation
## Log Visualisation
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
# API Reference
## API Reference
<aname="module_local-web-server"></a>
<aname="module_local-web-server"></a>
## local-web-server
## local-web-server
@ -152,7 +132,7 @@ Returns a Koa application
| Param | Type | Description |
| Param | Type | Description |
| --- | --- | --- |
| --- | --- | --- |
| [options] | <code>object</code> | options |
| [options] | <code>object</code> | options |
| [options.blacklist] | <code>Array.<regexp></code> | a list of forbidden routes. |
| [options.forbid] | <code>Array.<regexp></code> | a list of forbidden routes. |
A static web-server for productive front-end development.
A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**.
**Requires node v4.0.0 or higher**.
## Synopsis
## Synopsis
From the folder you wish to serve, run:
Serve a directory on the default port:
```sh
```sh
$ ws
$ ws
serving at http://localhost:8000
serving at http://localhost:8000
```
```
If you wish to serve a different directory, run:
Blacklist certain paths, for example config files:
```sh
```sh
$ ws -d ~/mysite/
serving /Users/Lloyd/mysite at http://localhost:8000
$ ws --forbid .json .yml
serving at http://localhost:8000
```
```
If you wish to override the default port (8000), use `--port` or `-p`:
Reduce bandwidth with gzip compression:
```sh
```sh
$ ws --port 9000
serving at http://localhost:9000
$ ws --compress
```
```
To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
Specify a Single Page Application:
```sh
```sh
$ ws --compress
$ ws --spa index.html
```
```
## Install
## Install
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
### Globally
```sh
```sh
$ npm install -g local-web-server
$ npm install -g local-web-server
```
```
### Bundled with your project
## Distribute with your project
```sh
```sh
$ npm install local-web-server --save-dev
$ npm install local-web-server --save-dev
```
```
@ -71,24 +69,6 @@ $ npm install
$ npm start
$ npm start
```
```
### Logging
Passing a value to `--log-format` will write an access log to `stdout`.
Either use a built-in [morgan](https://github.com/expressjs/morgan) logger preset:
```sh
$ ws --log-format short
```
Or a custom [morgan](https://github.com/expressjs/morgan) log format:
```sh
$ ws -f ':method -> :url'
```
Or silence:
```sh
$ ws -f none
```
## Storing default options
## Storing default options
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
```json
```json
@ -139,7 +119,7 @@ You can set additional mime-type/extension mappings, or override the defaults by
## Log Visualisation
## Log Visualisation
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/wiki/Log-visualisation).
description:"If a format is supplied an access log is written to stdout. If not, a statistics view is displayed. Use a preset ('none', 'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method -> :url').",group:'server'
description:"If a format is supplied an access log is written to stdout. If not, a statistics view is displayed. Use a preset ('none', 'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method -> :url').",group:'server'