3

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 Answer 1

2

Add the source element in your environments array:

"source": "environments/environment.ts",
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.