Skip to main content

ci-cd

CI/CD

angular-cli

hot replace

app.module 通过 DoBootstrap 钩子,加载环境变量

@NgModule({
declarations: [AppComponent],
//...
entryComponents: [AppComponent]
})
export class AppModule implements DoBootstrap {

ngDoBootstrap(appRef: ApplicationRef) {
fetch('assets/config/environment.json', {
method: 'GET'
})
.then(next => next.json())
.then(next => (environment.application = next))
.then(next =>
// ...
appRef.bootstrap(AppComponent);
);
}
}

ref

Handling Angular environments in continuous delivery