Last active
July 9, 2020 08:08
-
-
Save Dok11/f76a21d63b6892a204be6f0e57d5c48b to your computer and use it in GitHub Desktop.
Angular debug tools (with HMR settings)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ApplicationRef, enableProdMode} from '@angular/core'; | |
import {enableDebugTools} from '@angular/platform-browser'; | |
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; | |
import {AppModule} from './app/app.module'; | |
import {environment} from './environments/environment'; | |
import {hmrBootstrap} from './hmr'; | |
if (environment.production) { | |
enableProdMode(); | |
} | |
const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule).then((module) => { | |
if (!environment.production) { | |
// ng.profiler.timeChangeDetection({record: true}) | |
const applicationRef = module.injector.get(ApplicationRef); | |
const appComponent = applicationRef.components[0]; | |
enableDebugTools(appComponent); | |
} | |
return module; | |
}); | |
if (environment.hmr) { | |
if (module[ 'hot' ]) { | |
hmrBootstrap(module, bootstrap); | |
} else { | |
console.error('HMR is not enabled for webpack-dev-server!'); | |
console.log('Are you using the --hmr flag for ng serve?'); | |
} | |
} else { | |
bootstrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment