Currently, I am working on a project using AngularJS, Typescript, and VisualStudio. One of the key requirements for this project is to have a configuration file containing constants that control various settings such as REST API URLs and environment names. How can I achieve this in a project like this?
I was thinking of having a development config file called app.dev.config.ts
, structured like this:
module app.config {
export class ConfigSettings {
static environment(): string { return "dev"; }
static dataApiBaseUrl(): string { return "DevDataService"; }
}
}
and also having a app.prod.config.ts
like this:
module app.config {
export class ConfigSettings {
static environment(): string { return "prd"; }
static dataApiBaseUrl(): string { return "PrdDataService"; }
}
}
However, I quickly realized that having these two classes with the same name won't actually work.
I need a solution where I can build this only once on my build server and then deploy it to a fixed number (3) of environments. Perhaps this involves renaming a config file during deployment to match the specific environment. This is a process I'm familiar with from working on C# projects and their config files.
I've tried looking online for solutions to this issue, but all I came across were references to tsconfig.json
files.