diff --git a/templates/Angular2Spa/ClientApp/boot-client.ts b/templates/Angular2Spa/ClientApp/boot-client.ts index 6ac7dfb..75bd9a0 100644 --- a/templates/Angular2Spa/ClientApp/boot-client.ts +++ b/templates/Angular2Spa/ClientApp/boot-client.ts @@ -1,16 +1,21 @@ import 'angular2-universal-polyfills/browser'; -import 'bootstrap'; -import './styles/site.css'; import { enableProdMode } from '@angular/core'; import { platformUniversalDynamic } from 'angular2-universal'; import { AppModule } from './app/app.module'; -enableProdMode(); -platformUniversalDynamic().bootstrapModule(AppModule); +// Include styles in the bundle +import 'bootstrap'; +import './styles/site.css'; -// Basic hot reloading support. Automatically reloads and restarts the Angular 2 app each time -// you modify source files. This will not preserve any application state other than the URL. -declare var module: any; -if (module.hot) { - module.hot.accept(); +// Enable either Hot Module Reloading or production mode +const hotModuleReplacement = module['hot']; +if (hotModuleReplacement) { + hotModuleReplacement.accept(); + hotModuleReplacement.dispose(() => { platform.destroy(); }); +} else { + enableProdMode(); } + +// Boot the application +const platform = platformUniversalDynamic(); +platform.bootstrapModule(AppModule);