Is it possible to generate assets/files on build in our Angular app using environment variables?
We are looking to create an 'auth/settings.js' file in the assets folder with client id's and apiUrl's unique to each environment. These values will be used in the index.html outside of the angular app bootstrap.
For example, we would like to export the values in the environment.ts file into a js/json file outputted to the assets folder for use in index.html
export const environment = {
production: false,
title: 'default',
clientId: 'xxxx-xxxx-xxxx-xxxx-xxxx',
clientUrl: 'https://localhost:4200/app',
apiUrl: 'https://localhost/api'
};
I have come across the concept of multiapps which might help:
https://github.com/angular/angular-cli/wiki/stories-multiple-apps
However, the process seems quite manual and repetitive, as we will have multiple versions of the build. Is there a way to declare common settings once and extend them for extra app settings (inheritance)?
Thank you