Angular-cli beta 14 – How to import Environment

angularangular-cliwebpack

I just updated to the latest angular-cli (beta 14) which now uses webpack instead of systemjs.

I used to be able to import constants from the config/environment{prod|dev}.ts by simply importing it à la import { BASE_URL } from '../environment'. This doesn't work any more.
Environments are now defined in angular-cli.json and point to environments/environment{.prod}.ts but how do I access them in my components?

Best Answer

Simply import in the environment.ts file and at build time the appropriate environments file will be supplied based upon the environment (dev/prod)

import { environment } from '../environments/environment';
Related Topic