custom build command per environment

Is it possible to define a custom build command for an Angular app based on the environment? I need to trigger different npm scripts depending on the railway "ng build --configuration railway "ng build --configuration railway-staging",
16 Replies
Percy
Percy7mo ago
Project ID: d17c573a-a1a2-404c-8095-3e38320f6362
Dynamic Reel
Dynamic Reel7mo ago
d17c573a-a1a2-404c-8095-3e38320f6362
Brody
Brody7mo ago
use an environment variable for the configuration value
Dynamic Reel
Dynamic Reel7mo ago
That cannot be done in the package.json in the Angulatr project, can it? Also I am not using Dockerfile. And Angular cannot access environment variables for build, can it?
Brody
Brody7mo ago
you can change the scripts in the package.json to use an environment variable, then set the appropriate service variable in the service settings
Dynamic Reel
Dynamic Reel7mo ago
That is awesome! I didn’t know you could do that. Thank you so much.
Brody
Brody7mo ago
no problem! where you able to get a working implementation?
Dynamic Reel
Dynamic Reel7mo ago
Yes. I now have independent development and staging environments
Brody
Brody7mo ago
awesome, would you care to share examples for anyone reading in the future?
Dynamic Reel
Dynamic Reel7mo ago
Sure. How would I do that?
Brody
Brody7mo ago
just send examples of your start commands and such
Dynamic Reel
Dynamic Reel7mo ago
Right here in our chat?
Brody
Brody7mo ago
yes of course use triple backticks for code blocks
Dynamic Reel
Dynamic Reel7mo ago
Alright, will do Thanks again. May I ask you: Are you actually a bot? You answered so quickly
Brody
Brody7mo ago
I'm not a bot, was already on my phone with discord open and you asked an easy question so I just answered
Dynamic Reel
Dynamic Reel7mo ago
😅