I am trying to use an environment variable in my angular.json file. I suspect this isn't possible, but thought I would see if anyone knew how. I am using it to point to a signalr file generated by the server (issue being when in dev vs. staging it's a different baseUrl). So... angular.json
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ab-inbev-web2": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.json",
"assets": [
"src/assets",
"src/favicon.ico"
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.min.js",
"http://site-dev.com/signalr/hubs"
and when on staging
"http://site-stage.com/signalr/hubs"
]
environment.ts
export const environment = {
baseUrlWithSlash: 'http://site-prod.com/',
logoffWarningTimeoutSeconds: 600,
production: true,
searchDelimiters: /[,;\n]+/
};
environment-local.ts
export const environment = {
baseUrlWithSlash: 'http://site-dev.com/',
logoffWarningTimeoutSeconds: 600,
production: true,
searchDelimiters: /[,;\n]+/
};
ect...
I am trying to avoid hard coding it and trying to have it work while running local. I thought maybe there is a way to sniff the location in the angular.json file and do an if statement.