Reputation: 14586
Im developing an Angular 6 application using CLI 6.0.5.
I have two files with environment variables:
environments.ts
and environments.prod.ts
.
When I build for production (ng run build --prod
), the production variables are used. Running test server (npm start
) uses test variables.
Question: How can I run test server with production variables?
Upvotes: 0
Views: 1518
Reputation:
You are meddling your commands a little. Let's recap :
npm start
Runs the start
command declared in your package.json
ng run build --prod
Doesn't exist (that I know of). It's either ng build --prod
or npm run build -- --prod
Now, if you want to use different environments, the command is
ng serve --env prod
ng serve --configuration prod
The former is for Angular < 5, the latter is for Angular 6.
To be sure that you run the good command, simply run
ng serve --prod
This will run in production mode, which can be set up in your angular[-cli].json
file.
You of course have to declare those environments/configuration in your angular[-cli].json
file.
Upvotes: 1
Reputation: 1466
You can change environment using --prod
option while running it with angular cli.
This is the link for its doc you can refer for more options.
ng serve --prod
Happy Coding!!
Upvotes: 1