use module-dir
This commit is contained in:
18
README.md
18
README.md
@ -5,28 +5,28 @@
|
||||
[](https://github.com/feross/standard)
|
||||
[](https://gitter.im/lwsjs/local-web-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
***Requires node v7.6 or higher. Install the [previous release](https://github.com/lwsjs/local-web-server/tree/v1.x) for older node support. Documentation still WIP.***
|
||||
***Requires node v7.6 or higher. Install the [previous release](https://github.com/lwsjs/local-web-server/tree/v1.x) for node >= v4.0.0. Documentation still WIP.***
|
||||
|
||||
# local-web-server
|
||||
|
||||
The productive development web server. Built on [lws](https://github.com/lwsjs/lws).
|
||||
The development web server for productive front-end and full-stack Javascript engineers. Built on [lws](https://github.com/lwsjs/lws).
|
||||
|
||||
**Features**
|
||||
|
||||
- Fast and lightweight. Supports most common web application styles:
|
||||
- Static site.
|
||||
- Single Page Application (client-side rendering, web service consumption).
|
||||
- Server-rendered content.
|
||||
- Configurable with sensible defaults. Configure by constructor option, command-line option, stored config or all three.
|
||||
- Fast and lightweight.
|
||||
- Use the built-in features, a subset of the built-ins or your own feature stack
|
||||
- Configurable with sensible defaults.
|
||||
- Configure by constructor option, command-line option, stored config or all three.
|
||||
- HTTP or HTTPS ([HTTP2](https://github.com/nodejs/http2) will be added once ready)
|
||||
- URL rewriting
|
||||
- Local rewrites for quick experimentation (e.g. from `/img/logo.svg` to `/img/new-logo.svg`)
|
||||
- Rewrite to remote resources (e.g. from `/api/*` to `https://example-api.pl/api/$1`). *Note: ignores remote server's CORS policy, which during development is typically what you want*.
|
||||
- Optimised default caching strategy. Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
|
||||
- Optimisal caching by default.
|
||||
- Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
|
||||
- Configurable log output, compatible with [Goaccess, Logstalgia and glTail](https://github.com/lwsjs/local-web-server/blob/master/doc/visualisation.md)
|
||||
- Configurable CORS rules. All origins allowed by default.
|
||||
|
||||
**Use cases**
|
||||
**Links to demoes and how-tos**
|
||||
|
||||
Things you can build:
|
||||
|
||||
|
11
bin/cli.js
11
bin/cli.js
@ -2,4 +2,13 @@
|
||||
'use strict'
|
||||
const LocalWebServer = require('../')
|
||||
const localWebServer = new LocalWebServer()
|
||||
localWebServer.start()
|
||||
try {
|
||||
localWebServer.start()
|
||||
} catch (err) {
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
console.error(err.message)
|
||||
console.error(require('util').inspect(err.attempted, { depth: 6, colors: true }))
|
||||
} else {
|
||||
console.error(err.stack)
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ const Lws = require('lws')
|
||||
class LocalWebServer extends Lws {
|
||||
constructor (options) {
|
||||
const path = require('path')
|
||||
const stack = [
|
||||
let stack = [
|
||||
'lws-log',
|
||||
'lws-cors',
|
||||
'lws-json',
|
||||
@ -25,10 +25,9 @@ class LocalWebServer extends Lws {
|
||||
'lws-spa',
|
||||
'lws-static',
|
||||
'lws-index'
|
||||
].map(name => {
|
||||
return path.resolve(__dirname, `../node_modules/${name}`)
|
||||
})
|
||||
options = Object.assign({ stack }, options)
|
||||
]
|
||||
const moduleDir = path.resolve(__dirname, `../node_modules`)
|
||||
options = Object.assign({ stack, 'module-dir': moduleDir, prefix: 'lws-' }, options)
|
||||
super(options)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user