srv-it
v0.5.1
Published
Static server with polished CLI UI, directory listing, and live reload
Maintainers
Readme
srv-it
srv-it is a simple cli that merges the best parts of live-server and serve:
- one-command static server from any folder
- polished terminal UX
- live DOM reload and CSS refresh
- directory listing with customizable page style
- simple defaults via config files
Quick start
npm install -g srv-itThen run:
cd your-project
srv-itThis serves the current directory on port 3000.
Common usage
srv-it
srv-it 3000
srv-it 8080 ./public
srv-it ./public --open
srv-it --style paper --style-css ./srv-listing.cssConfig defaults
You can set defaults globally and per-project:
- global:
~/.srvrc.json - project:
./srv.config.json - override file:
srv-it --config ./my-srv.json - template:
./srv.config.example.json
Example srv.config.json:
{
"port": 3000,
"host": "0.0.0.0",
"open": false,
"single": true,
"cors": true,
"style": "midnight",
"directoryListing": true,
"noCssInject": false,
"logLevel": 2,
"noRequestLogging": false,
"ignore": ["**/.git/**", "**/node_modules/**"]
}CLI flags always override config files.
CLI options
Run:
srv-it --helpSupported Arguments
-h, --help: show help output-v, --version: print the current version-p, --port <number>: set the server port--host <host>: set the bind host (default:0.0.0.0)--open [path]: open a browser to/or the provided path--no-open: disable automatic browser opening--watch <path>(repeat): add extra files/folders to watch for live reload--ignore <glob>(repeat): ignore matching watcher paths/globs--no-css-inject: use full page reload for CSS changes instead of hot CSS refresh--cors: enable CORS headers--single: serveindex.htmlfor unknown routes (SPA fallback)--no-dir-listing: disable generated directory listing pages--style <midnight|paper>: choose the directory listing style preset--style-css <file>: load custom CSS for directory listing pages-c: createsrv.config.jsonin the served root if missing--config <file>: read additional config JSON file--no-request-logging: disable request logs--log-level <0-3>: set startup log verbosity--ssl-cert <file>: path to SSL certificate--ssl-key <file>: path to SSL private key--ssl-pass <file>: path to SSL passphrase file
Notes
- HTML pages get an auto-injected websocket client for live reload.
- CSS changes refresh styles without full page reload unless
--no-css-injectis enabled. - If a folder has
index.html, that file is served; otherwise a styled directory listing is shown. - Watch mode always ignores
.gitandnode_modules, and also skips common home cache/config paths (~/.cache,~/.local/share). - If the OS watcher limit is reached (
ENOSPC), srv-it keeps serving files and disables live reload instead of crashing.
