DEV Community

Discussion on: Using shared settings between multiple environments in Angular 🚀

Collapse
 
kinaski profile image
kinaski

Is it possible to create extra .prod environment and to run command like:
"ng build --prod --configuration new_environment" .
I want to have optimised files.

Collapse
 
rmcsharry profile image
Richard McSharry • Edited

Yes you can do this. Just don't use the --prod flag.

"ng build --configuration my_special_config"

in angular.json add "my_special_config"

If you wanted to apply everything that you've configured already for the production build, but overwrite/add some settings then still create it in angular.json and then:

"ng build --configuration production, my_special_config"

See angular.io/guide/workspace-config#...

Collapse
 
nikosanif profile image
Nikos Anifantis

Thanks for your comment @kinaski !
Unfortunately as far I know, you cannot do this! If you can see the official documentation, setting the --configuration option explicitly overrides the --prod flag.
For more information, see: angular.io/cli/build#options