proxy-hot-reload
Node.js application hot reload with Proxy
.
NB: proxy-hot-reload can only proxy modules that return an plain object, like:
moduleexport = ... // orexportsxxx = ...
Install
$ npm i proxy-hot-reload --save
Example
app.js
'use strict'; if processenvNODE_ENV !== 'production' includes: '**/*.js' ; const express = ;const app = ;const user = ; app app;
user.js
moduleexports = id: 1 age: 19
DEBUG=proxy-hot-reload node app.js
Then try to modify user.js, access to localhost:3000
.
Usage
require('proxy-hot-reload')([option])
option:
- includeFiles([obsolute filepath]) || includes(glob pattern string): as
PROXY_HOT_RELOAD_INCLUDES
, files should be includes, see glob. - excludeFiles([obsolute filepath]) || excludes(glob pattern string): as
PROXY_HOT_RELOAD_EXCLUDES
, files should be excludes, see glob. - watchedFileChangedButNotReloadCache: default:
{ }
Note
- proxy-hot-reload should not be used in production environment.
- proxy-hot-reload is effective for some specific files like:
lib/*.js
,utils/*.js
etc.
If you find some bugs please raise an issue or make a pull request.
License
MIT