Merge branch 'master' into next
This commit is contained in:
@ -20,7 +20,7 @@ For the examples below, we assume we're in a project directory looking like this
|
||||
└── package.json
|
||||
```
|
||||
|
||||
All paths/routes are specified using [express syntax](http://expressjs.com/guide/routing.html#route-paths).
|
||||
All paths/routes are specified using [express syntax](http://expressjs.com/guide/routing.html#route-paths). To run the example projects linked below, clone the project, move into the example directory specified, run `ws`.
|
||||
|
||||
### Static site
|
||||
|
||||
@ -30,6 +30,8 @@ $ ws
|
||||
serving at http://localhost:8000
|
||||
```
|
||||
|
||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/simple).
|
||||
|
||||
### Single Page Application
|
||||
|
||||
You're building a web app with client-side routing, so mark `index.html` as the SPA.
|
||||
@ -41,6 +43,8 @@ By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Fo
|
||||
|
||||
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*
|
||||
|
||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/spa).
|
||||
|
||||
### Access Control
|
||||
|
||||
By default, access to all files is allowed (including dot files). Use `--forbid` to establish a blacklist:
|
||||
@ -49,6 +53,8 @@ $ ws --forbid '*.json' '*.yml'
|
||||
serving at http://localhost:8000
|
||||
```
|
||||
|
||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/forbid).
|
||||
|
||||
### URL rewriting
|
||||
|
||||
Your application requested `/css/style.css` but it's stored at `/build/css/style.css`. To avoid a 404 you need a rewrite rule:
|
||||
@ -86,6 +92,8 @@ Map local requests for repo data to the Github API:
|
||||
$ ws --rewrite '/:user/repos/:name -> https://api.github.com/repos/:user/:name'
|
||||
```
|
||||
|
||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/rewrite).
|
||||
|
||||
### Stored config
|
||||
|
||||
Use the same port and blacklist every time? Persist it to `package.json`:
|
||||
@ -160,6 +168,8 @@ You can set additional mime-type/extension mappings, or override the defaults by
|
||||
}
|
||||
```
|
||||
|
||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/mime-override).
|
||||
|
||||
#### Log Visualisation
|
||||
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md).
|
||||
|
||||
|
Reference in New Issue
Block a user