3
votes

I try to use angular-cli to configure the environment setting from https://github.com/angular/angular-cli#build-targets-and-environment-files

But after I run "ng build --prod -aot", the output pages still show the content from original environment/environment.ts. I expect this file will be overwritten by environment/environment.prod.ts, but it looks like not.

My folder structure is like:

  • angular-cli.json
  • ...
  • src/
    • app/
      • ...
    • environment/
      • environment.dev.ts
      • environment.prod.ts
      • environment.ts
    • main.ts
    • ...

My angular-cli.json:

"apps": [
{
  "root": "src",
  ...,
  "environments": {
    "dev": "environments/environment.dev.ts",
    "prod": "environments/environment.prod.ts"
  }
  ...

In my main.ts file, I import the "environment":

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

And here is my ng version:

angular-cli: 1.0.0-beta.22-1 node: 6.9.1 os: win32 x64

Does any one know what's wrong with me? Really thanks.

1

1 Answers

2
votes

Add the source element in your environments array:

"source": "environments/environment.ts",