How to specify environment via `ng build` in Angular 6 app

Nehal Damania picture Nehal Damania · May 10, 2018 · Viewed 17.6k times · Source

In Angular 5, we could generate build for different environments using

ng build --prod --env=uat

After migration to Angular 6 the above command throws error

Unknown option: '--env'

Answer

Nehal Damania picture Nehal Damania · May 10, 2018

One needs to use the configuration option

ng build --prod --configuration=uat

or

ng build --prod -c uat

More information here

Also for ng serve same option as answered here