srvs v0.6.3
srvs serves modern webapps for dev, with none of the fat
srvs is a zero dependency dev server with support for static content in addition to JavaScript modules hosted from local files and esm.sh.
Installation
Global
npm i -g srvsThen you may run with:
srvsnpx
No install required, just run:
npx srvs(npx comes with npm 5.2+ and higher.)
Local
Install with npm / Yarn:
npm i -D srvsThen add srvs to the scripts in your package.json:
"scripts": {
"start": "srvs"
}Now you may run with:
npm startUsage
Command Line
Here are the available command line arguments:
| Argument | Usage | Default |
|---|---|---|
| port | The port on which the dev server will listen. | 8080 |
| docRoot | The relative path from which static assets such as index.html will be served. | public |
| scriptRoot | The relative path from which local JavaScript modules will be served. | src |
Each argument is passed in the form --argument=value. Here is an example using all available arguments:
npx srvs --port=3000 --docRoot=static --scriptRoot=jsAPI
srvs offers a programmatic way to integrate running with existing JavaScript code.
You may bring in the srvs API function using import if you have support for ES6 syntax:
import srvs from "srvs";
srvs(options).then(config => {
// dev server is now open for business
});Or using require:
const srvs = require("srvs");
srvs(options).then(config => {
// dev server is now open for business
});The options object has the same properties and values as the arguments supported by the command line version. The config parameter provided to the resolved Promise has the same properties as options.
Notes
- This is only for use as a development tool, please do not use in production.
- The
docRootandscriptRootoptions will fall back to the current directory if they don't exist. - The
BROWSERenvironment variable can be used to control which application to open your page in, or set tononeto disable browser opening entirely. This feature is inspired by the popularcreate-react-app.
License
srvs is MIT licensed. See LICENSE.
1 year ago
1 year ago
1 year ago
1 year ago
5 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago