angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build -prod not using environment.prod.ts

Open ruinunes-parkbee opened this issue 9 years ago • 4 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> I have search for this issue, but every 'workaround' found did not work in my case
- [ ] feature request

Versions.

@angular/cli: 1.2.6 node: 6.11.1 os: darwin x64 @angular/animations: 4.3.2 @angular/cdk: 2.0.0-beta.8 @angular/common: 4.3.2 @angular/compiler: 4.3.2 @angular/core: 4.3.2 @angular/forms: 4.3.2 @angular/http: 4.3.2 @angular/material: 2.0.0-beta.8 @angular/platform-browser: 4.3.2 @angular/platform-browser-dynamic: 4.3.2 @angular/router: 4.3.2 @angular/cli: 1.2.6 @angular/compiler-cli: 4.3.2 @angular/language-service: 4.3.2

Repro steps.

Im trying to deploy an angular cli app to production but im unable to use environment.prod.ts as the environment file. It keep falling back to environment.ts. Im using appveyor to do the deployment and on my build script I execute ng build -prod which it builds and creates the dist folder, but when i upload that folder to the server the app is using the development environment file. I have tried everything on the internet already but no luck. What have I tried already: ng build --prod ng build -prod ng build --target=production --environment=prod I have updated angular cli to the latest version.

The log given by the failure.

no errors in the logs when building

Desired functionality.

It would be really nice to use environment.prod.ts in production instead

Mention any other details that might be useful.

my .angular-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "parkbee.owners-dashboard"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "configuration",
        "config.js",
        "deploy.ps1"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

ruinunes-parkbee avatar Aug 01 '17 13:08 ruinunes-parkbee

After to many hours looking at this I could not see the problem. Running ng build -prod actually do work. I was getting a different error on my page but was seeing it as the same error in my head. Will close this issue since there is actually no problems

ruinunes-parkbee avatar Aug 01 '17 13:08 ruinunes-parkbee

I have the same problem.... Have you found a solution?

raugaral avatar Mar 16 '18 14:03 raugaral

I set some atributtes to environment object according context, but always get environment.ts file values. :/

marylly avatar May 16 '18 14:05 marylly

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.