Reputation: 4081
I have few different configurations for different environments and clients in my angular.json file.
My question is, if there is a way to, instead of typing all the configurations inside angular.json, specify just the file path to json file for each specific configuration?
Upvotes: 1
Views: 697
Reputation: 12357
An approach for this is to create an npm
script that updates the angular.json
with the required configurations
"scripts": {
"start": "ng serve",
"build": "ng build",
"config:angular": "node config-angular.js"
}
// on the command line
npm run config:angular -- --config=client
In your config-angular.js
file you'd read the arguments e.g. --config=client
- here's a good article to follow for the arguments: Pass arguments from the command line to a Node script
You can then update the angular.json
with the contents of an imported client-config.js
file (or whatever the configs are names). There's a lot of helper npm
modules for reading and writing to and from JS/JSON files
If you're taking this approach it's a good idea to write a unit test for config-angular.js
, and also to output a backup of the angular.json file before each update
Upvotes: 1