{"id":17242841,"url":"https://github.com/imcuttle/simple-hot-reload-server","last_synced_at":"2025-04-14T03:25:53.950Z","repository":{"id":57360236,"uuid":"86480599","full_name":"imcuttle/simple-hot-reload-server","owner":"imcuttle","description":"simple hot reload server by nodejs","archived":false,"fork":false,"pushed_at":"2022-01-07T14:58:14.000Z","size":125,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T02:34:05.561Z","etag":null,"topics":["hot-reload","nodejs","server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imcuttle.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-28T16:06:28.000Z","updated_at":"2024-11-10T20:44:45.000Z","dependencies_parsed_at":"2022-09-06T22:22:04.061Z","dependency_job_id":null,"html_url":"https://github.com/imcuttle/simple-hot-reload-server","commit_stats":null,"previous_names":["moyuyc/simple-hot-reload-server"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fsimple-hot-reload-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fsimple-hot-reload-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fsimple-hot-reload-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fsimple-hot-reload-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imcuttle","download_url":"https://codeload.github.com/imcuttle/simple-hot-reload-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814739,"owners_count":21165818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hot-reload","nodejs","server"],"created_at":"2024-10-15T06:14:14.254Z","updated_at":"2025-04-14T03:25:53.932Z","avatar_url":"https://github.com/imcuttle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Hot Reload Server\n\n[![NPM](https://nodei.co/npm/simple-hot-reload-server.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/simple-hot-reload-server)\n\n[中文文档点这](https://imcuttle.github.io/say-goodbye-to-manual-refresh)\n\nSet up a server for frontend files(html/css/js/favicon) \u0026 Watch frontend files.\n\nconnected server and client by WebSocket.\n\n## Feature\n\n- **Hot Reload**\n![](https://ooo.0o0.ooo/2017/03/31/58de5c97bfa0b.jpg)\n\n- **Debugger**\n![](https://ooo.0o0.ooo/2017/03/31/58de5c83f0eac.jpg)\n\n- **Files View (Easy to open page in root)**  \n`http://localhost:8082/__hrs__/file`\n![](https://ooo.0o0.ooo/2017/04/01/58df9961dd9b2.jpg)\n\n- **Source Map Preview**\n\n    1. Single  \n        `http://localhost:8082/index.html.hrs.map`\n        ```json\n        {\n            \"/Users/moyu/my-code/JavaCode/dike/js/jquery-1.9.1.js\": \"../../js/jquery-1.9.1.js\",\n            \"/Users/moyu/my-code/JavaCode/dike/js/bootstrap.js\": \"../../js/bootstrap.js\",\n            \"/Users/moyu/my-code/JavaCode/dike/js/navbar.js\": \"../../js/navbar.js\",\n            \"/Users/moyu/my-code/JavaCode/dike/css/font-awesome.min.css\": \"../../css/font-awesome.min.css\",\n            \"/Users/moyu/my-code/JavaCode/dike/css/navbar.css\": \"../../css/navbar.css\",\n            \"/Users/moyu/my-code/JavaCode/dike/css/conceptModel.css\": \"../../css/conceptModel.css\",\n            \"/Users/moyu/my-code/JavaCode/dike/css/dropzone/dropzone.css\": \"../../css/dropzone/dropzone.css\"\n        }\n        ```\n    2. Total  \n        `http://localhost:8082/__hrs__/map`\n\n- **Forward Request**  \n    `http://localhost:8082/__hrs__/forward?url=http://blog.moyuyc.xyz/head.jpg`\n    \n- **Config**  \n    Be Named `hrs.config.js` on current work directory.\n    ```js\n    module.exports = {\n        proxy: {\n            \"/api\": {\n                target: \"http://www.huya.com/longdd\",\n            },\n            \"/php\": {\n                redirect: true, // default: true\n                target: \"http://localhost:63343/start/static\",//\"http://localhost:6999\",\n                changeHost: true,  // default: true\n    \n                hot: true, // hot reload enable? default: false\n                // Function/RegExp: will be set root config hotRule if it is null\n                hotRule: function (filename, request) {\n                    // console.log(request.url);\n                    return /\\.(php)$/.test(filename);\n                },\n                // Function: return local file path\n                mapLocal: function (request) {\n                    // request: Express Request Object\n                    // console.log('mapLocal', request.originalUrl, request.baseUrl, request.url);\n                    const url = request.url.replace(/\\?[\\s\\S]*/, '')\n                    return \"/Users/moyu/my-code/phpCode/start/static\" + url;\n                },\n                // Function/String: return detected directory path\n                mapRoot: function (request) {\n                    // request: Express Request Object\n                    return \"/Users/moyu/my-code/phpCode/start/static\";\n                }\n            },\n        },\n    \n        // RegExp or function (filename) {...}\n        hotRule: /\\.(html|htm)$/, // default: /\\.(html|htm)$/\n    \n        setUp: function (app) {\n            /* app is an express server object. */\n    \n            // http://localhost:8082/test\n            app.get('/test', function (req, res) {\n                res.end(\"TEST!\");\n            });\n        }\n    };\n    ```\n\n## Install\n\n```bash\nnpm install -g simple-hot-reload-server\n```\n\n```text\nUsage: hrs [-p port] path\n\nOptions:\n\n  -v --version                get current version.\n  -p --port                   set port of server. (default: 8082)\n  -c --config                 config path. (default hrs.config.js)\n  -h --help                   how to use it.\n```\n\n## Others\n\n**Support Local Server**  \n*Importance: Only support files which filename ends with `.html/.htm` or is required by html/htm*\n1. set up an node server\n    ```bash\n    hrs path/to/front/root    \n    ```\n2. open html in address\n    ```\n    http://localhost:8082/where?dubug=true\u0026reload=true\n    ```\n    `debug`: whether `console.log/error/...` on browser could print on node server. **default: false**  \n    `reload`: whether reload when file changed. **default: true**\n\n**Support CORS**  \n*Importance: support all files (php/jsp/asp...)*\n\n1. set up an node server\n    ```bash\n    hrs\n    ```\n2. insert script in HTML manually.\n    ```html\n    \u003cscript\n        src=\"http://localhost:8082/__hrs__/client-script.js?reload=false\u0026debug=true\"\n        hrs-local=\"/Users/moyu/fe-code/a/b/jsonp.html\"\n        hrs-root=\"/Users/moyu/fe-code\"\n    \u003e\n    \u003c/script\u003e\n    ```\n    `hrs-local`: map to local html file  \n    `hrs-root`: node server detect the directory for hot reload.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fsimple-hot-reload-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimcuttle%2Fsimple-hot-reload-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fsimple-hot-reload-server/lists"}