Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spa): environment not loaded in app module #692

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion apps/spa/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@
</head>
<body>
<noscript>Bitte aktivieren Sie JavaScript um Kordis zu nutzen.</noscript>
<kordis-root ngCspNonce="csp_nonce"></kordis-root>
<kordis-root ngCspNonce="csp_nonce">
<style>
.loader-container {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
width: 100%;
height: 100vh;
}

.loader {
width: 72px;
height: 72px;
border: 8px solid #1890ff;
border-bottom-color: transparent;
border-radius: 50%;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}

@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>

<div class="loader-container">
<span class="loader"></span>
</div>
</kordis-root>
</body>
</html>
13 changes: 6 additions & 7 deletions apps/spa/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { DynamicConfig } from './environments/dynamic-config.model';
import { environment } from './environments/environment';

Expand All @@ -11,9 +10,9 @@ fetch('./assets/config.json')
...(config as DynamicConfig),
...environment,
});

platformBrowserDynamic()
.bootstrapModule(AppModule)
// eslint-disable-next-line no-console
.catch((err) => console.error(err));
});
})
// we have to dynamically import the module, so the environment does not get evaluated before the fetch
.then(() => import('./app/app.module'))
.then(({ AppModule }) => platformBrowserDynamic().bootstrapModule(AppModule))
// eslint-disable-next-line no-console
.catch((err) => console.error(err));