- Notifications
You must be signed in to change notification settings - Fork0
okwolf/srvs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
srvs
is a zero dependency dev server with support for static content in addition to JavaScript modules hosted from local files andesm.sh.
npm i -g srvs
Then you may run with:
srvs
No install required, just run:
npx srvs
(npx comes with npm 5.2+ and higher.)
Install with npm / Yarn:
npm i -D srvs
Then addsrvs
to thescripts
in yourpackage.json
:
"scripts": {"start":"srvs"}
Now you may run with:
npm start
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 asindex.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=js
srvs
offers a programmatic way to integrate running with existing JavaScript code.
You may bring in thesrvs
API function usingimport
if you have support for ES6 syntax:
importsrvsfrom"srvs";srvs(options).then(config=>{// dev server is now open for business});
Or usingrequire
:
constsrvs=require("srvs");srvs(options).then(config=>{// dev server is now open for business});
Theoptions
object has the same properties and values as the arguments supported by the command line version. Theconfig
parameter provided to the resolvedPromise
has the same properties asoptions
.
- This is only for use as a development tool, please do not use in production.
- The
docRoot
andscriptRoot
options will fall back to the current directory if they don't exist. - The
BROWSER
environment variable can be used to control which application to open your page in, or set tonone
to disable browser opening entirely. This feature is inspired by the popularcreate-react-app
.
srvs
is MIT licensed. SeeLICENSE.
About
zero dependency dev server