- C++ 98.3%
- CMake 1.7%
| .forgejo/workflows | ||
| .github/workflows | ||
| external | ||
| src | ||
| .gitignore | ||
| CMakeLists.txt | ||
| LICENSE | ||
| README.md | ||
liveserver
An extremely small Linux-only static dev server written in C++.
It serves a directory, picks an available port, injects a browser reload client into HTML files, watches files for changes, and refreshes connected browsers over a WebSocket.
CSS changes are reloaded by swapping stylesheet links. Other changes cause a full page refresh.
Build
cmake -S . -B build
cmake --build build
The compiled binary is created at build/liveserver.
Install
Install to the default CMake prefix:
sudo cmake --install build
Usage
Serve the current directory:
liveserver
Serve a specific directory:
liveserver ./dist
Choose a preferred port:
liveserver ./dist --port 5173
If that port is busy, liveserver automatically tries the next available port. Use --strict-port to fail instead.
Bind to a specific host:
liveserver ./dist --host 0.0.0.0
Open the browser automatically:
liveserver ./dist --open
Options
Usage: liveserver [directory] [options]
Options:
--port <port> Preferred port (default: 3000)
--host <addr> Bind host (default: 127.0.0.1)
--config <path> The path to load the liveserver config from
--strict-port Fail if --port is unavailable
--open Open the served URL in the default browser
--spa Fallback unknown paths to index.html
--ignore <glob> Ignore file watcher paths (repeatable)
--disable-logging Disable console logging
--verbose Show low-level connection logs
--no-color Disable ANSI colors
--no-live-reload Disable file watching and browser refresh
--poll <ms> File watch poll interval (default: 250)
--version Show version
--help Show help
Config
liveserver tries to load liveserver.json from the current directory. You can also pass a custom config path with --config.
liveserver --config ./server.json
CLI options override values from the config file. Example liveserver.json:
{
"root": "./dist",
"port": 5173,
"host": "0.0.0.0",
"openBrowser": true,
"spaFallback": true,
"pollMs": 250,
"ignore": [".cache", "node_modules"]
}
License
This project is licensed under the MIT License. See LICENSE.