The constants service I have maintains all the necessary constants for the application, such as the base URL of the backend.
export class ConstantsService {
public BACKEND_URL = 'http://10.0.27.176:8000/';
}
This setup is not very flexible because once the project is built, the BACKEND_URL
cannot be changed. I need a solution where I can export the BACKEND_URL
from a file that is included in the production build, allowing me to modify it post-build as well.
To address this limitation, I tried:
import {environment} from '../environments/environment.prod';
...
export class ConstantsService {
public BACKEND_URL = environment.url;
}
environment.prod.ts
export const environment = {
production: true,
url: 'http://10.0.27.176:8000/';
};
However, the issue I encountered was that the environment.prod.ts
file was not present in the build.
If anyone could suggest a way for me to achieve this goal, I would greatly appreciate it.
Edit: Below is my prod build output. The environment.prod.ts file is missing:
Date: 2018-09-11T11:52:10.945Z
Hash: 96c48ccf441d2f7a204f
Time: 9301ms
chunk {scripts} scripts.3af8bf49d802296d8ab1.js (scripts) 174 kB [rendered]
chunk {0} 0.d9c510e0e0d04dde4c78.js () 1.27 kB [rendered]
chunk {1} runtime.a18a7eb7c080a20cb142.js (runtime) 1.84 kB [entry] [rendered]
chunk {2} styles.0260add3f34224e145b6.css (styles) 5.58 kB [initial] [rendered]
chunk {3} polyfills.92108b287fe28032870b.js (polyfills) 59.6 kB [initial] [rendered]
chunk {4} main.4bbca11d5e8a6cdb36c0.js (main) 316 kB [initial] [rendered]