vicgoyso
vicgoyso

Reputation: 616

Angular 2 environment not working

I have set up an angular 2 application with development fetching data from the local computer hence json-server and the production fetches from the live API.

I believed typing "ng serve --environment=prod" in the terminal would launch the app using the "environment.prod.ts", production file instead of the dev file.

However this is not the case, i see nothing that reflects the difference in settings in the preview.

Please can someone point out where I am going wrong?

Upvotes: 1

Views: 846

Answers (1)

SaxyPandaBear
SaxyPandaBear

Reputation: 377

Did you use ng serve --prod or ng serve --environment prod or ng serve -e prod? Also, make sure in your .angular-cli.json file that "environments" has prod defined. Do note that the Angular CLI tool doesn't really do anything when generating the two environment ts files. They both have a boolean that is true if you use prod and false otherwise. If you didn't set anything in the environment files, you're not going to see any difference.

Finally, it seems that ng serve --prod may not be a good way to deploy your code https://github.com/angular/angular-cli/issues/5274

Upvotes: 2

Related Questions