Simple Hot Reload Server
Set up a server for frontend files(html/css/js/favicon) & Watch frontend files.
connected server and client by WebSocket.
Feature
-
Hot Reload
-
Debugger
-
Files View (Easy to open page in root)
http://localhost:8082/__hrs__/file
-
Source Map Preview
- Single
http://localhost:8082/index.html.hrs.map
- Total
http://localhost:8082/__hrs__/map
- Single
-
Forward Request
http://localhost:8082/__hrs__/forward?url=http://blog.moyuyc.xyz/head.jpg
-
Config
Be Namedhrs.config.js
on current work directory.moduleexports =proxy:"/api":target: "http://www.huya.com/longdd""/php":redirect: true // default: truetarget: "http://localhost:63343/start/static"//"http://localhost:6999",changeHost: true // default: truehot: true // hot reload enable? default: false// Function/RegExp: will be set root config hotRule if it is null{// console.log(request.url);return /\.$/;}// Function: return local file path{// request: Express Request Object// console.log('mapLocal', request.originalUrl, request.baseUrl, request.url);const url = requesturlreturn "/Users/moyu/my-code/phpCode/start/static" + url;}// Function/String: return detected directory path{// request: Express Request Objectreturn "/Users/moyu/my-code/phpCode/start/static";}// RegExp or function (filename) {...}hotRule: /\.$/ // default: /\.(html|htm)$/{/* app is an express server object. */// http://localhost:8082/testapp;};
Install
npm install -g simple-hot-reload-server
Usage: hrs [-p port] path Options: -v --version get current version. -p --port set port of server. (default: 8082) -c --config config path. (default hrs.config.js) -h --help how to use it.
Others
Support Local Server
Importance: Only support files which filename ends with .html/.htm
or is required by html/htm
- set up an node serverhrs path/to/front/root
- open html in address
http://localhost:8082/where?dubug=true&reload=true
debug
: whetherconsole.log/error/...
on browser could print on node server. default: false
reload
: whether reload when file changed. default: true
Support CORS
Importance: support all files (php/jsp/asp...)
- set up an node serverhrs
- insert script in HTML manually.
hrs-local
: map to local html file
hrs-root
: node server detect the directory for hot reload.