extend environment and use injected app config

This commit is contained in:
William Welling
2021-12-06 16:54:55 -06:00
parent 71f5b46639
commit 33488ccf40
25 changed files with 742 additions and 1203 deletions

View File

@@ -11,13 +11,13 @@ import { hasValue } from './app/shared/empty.util';
import { BrowserAppModule } from './modules/app/browser-app.module';
import { environment } from './environments/environment';
import { AppConfig } from './config/app-config.interface';
import { extendEnvironmentWithAppConfig } from './config/config.util';
// import { AppConfig, APP_CONFIG } from './config/app-config.interface';
// import { extendEnvironmentWithAppConfig } from './config/config.util';
if (environment.production) {
enableProdMode();
}
const bootstrap = () => platformBrowserDynamic()
.bootstrapModule(BrowserAppModule, {
preserveWhitespaces: true
});
const main = () => {
// Load fonts async
@@ -28,10 +28,22 @@ const main = () => {
}
});
return platformBrowserDynamic()
.bootstrapModule(BrowserAppModule, {
preserveWhitespaces: true
});
if (environment.production) {
enableProdMode();
return bootstrap();
} else {
return fetch('assets/appConfig.json')
.then((response) => response.json())
.then((appConfig: AppConfig) => {
// extend environment with app config for browser when not prerendered
extendEnvironmentWithAppConfig(environment, appConfig);
return bootstrap();
});
}
};
// support async tag or hmr
@@ -40,11 +52,3 @@ if (hasValue(environment.universal) && environment.universal.preboot === false)
} else {
document.addEventListener('DOMContentLoaded', main);
}
// fetch('assets/appConfig.json')
// .then((response) => response.json())
// .then((appConfig: AppConfig) => {
// // extend environment with app config for client side use
// extendEnvironmentWithAppConfig(environment, appConfig);
// });