npm i @cloud/ng-hmr
require ng-hmr
and ApplicationRef
in entry:
import { ApplicationRef } from '@angular/core';
import { enableNgHmr, HotModuleRef } from 'ng-hmr';
warp bootstrapModule:
const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);
enableNgHmr(module as HotModuleRef)(ApplicationRef, bootstrap)
enjoy~
Enable in ng-cli,run with hmr option "ng serve --hmr"
or update package.json
insides scripts block with --hmr
"scripts": {
"start": "ng serve --hmr",
// other options...
}
then run "npm run start"
.
Note: Consider like follwing example.
ng-hmr is safe to use in production; it's leave a minimal footprint, so there is no need to complicate your configuration based on the environment.
see in other pageTroubleshooting