@m59/reload-server
v1.0.6
Published
Simple SPA development server with reload API. Injects reload script.
Downloads
4
Maintainers
Readme
Reload Server
Simple SPA development server with reload API. Injects reload script.
Install
npm install @m59/reload-server
CLI
m59-reload-server [options]
-h, --help output usage information
-V, --version output the version number
-d, --dir [value] directory of files to be served [cwd]
-p, --port [value] `port` argument for server.listen() [8080]
-H, --host [value] `host` argument for server.listen()
-q, --quiet disable logging
--wsPath [value] path to the websocket server
JS API
const Server = require('@m59/reload-server')
const server = Server({
dir: './www'
})
server.listen(8080)
watch(someFiles, function(event) {
server.reload(event.path) // smart reload based on path
})
Server(options)
options: object
dir: string, cwd
wsPath: string, random
quiet: boolean, false
- returns: server
server.reload(path)
Signals connected clients to reload the page. If path
is given, clients may be signaled to refresh CSS or images based on the file extension in the path, rather than reloading the page.
server.refreshCSS()
Signals connected clients to refresh CSS without page reload.
server.refreshImages()
Signals connected clients to refresh images without page reload.
server.wsPath
The path to the websocket server.
server.wss
The ws server.
HTTP API
POST /reload
POST /reload/css
POST /reload/img
The path
parameter of server.reload
can be passed as JSON in the body or as a query parameter.
{"path": "/path/here.css"}
/reload?path=/path/here.css
curl -X POST http://localhost:8080/reload