Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

zero dependency dev server

License

NotificationsYou must be signed in to change notification settings

okwolf/srvs

Repository files navigation

Build Statuscodecovnpm

srvs is a zero dependency dev server with support for static content in addition to JavaScript modules hosted from local files andesm.sh.

Installation

Global

npm i -g srvs

Then you may run with:

srvs

npx

No install required, just run:

npx srvs

(npx comes with npm 5.2+ and higher.)

Local

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

Usage

Command Line

Here are the available command line arguments:

ArgumentUsageDefault
portThe port on which the dev server will listen.8080
docRootThe relative path from which static assets such asindex.html will be served.public
scriptRootThe 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

API

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.

Notes

  • This is only for use as a development tool, please do not use in production.
  • ThedocRoot andscriptRoot options will fall back to the current directory if they don't exist.
  • TheBROWSER 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.

License

srvs is MIT licensed. SeeLICENSE.


[8]ページ先頭

©2009-2025 Movatter.jp