Why is the build configuration always choosing production?

33 Views Asked by At

I am experiencing a strange problem when building not picking up the correct configuration.

This is my angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "challenge-submission": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/challenge-submission",
            "index": "src/index.html",
            "main": "src/app/unleashed-elements/challenge-submission/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/app/unleashed-elements/challenge-submission/assets"
            ],
            "styles": [],
            "scripts": []
          },
          "configurations": {
            "development": {
              "buildOptimizer": true,
              "optimization": true,
              "vendorChunk": false,
              "extractLicenses": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.dev.ts"
                                }
                            ]
            },
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "2mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "5kb",
                  "maximumError": "10kb"
                }
              ],
              "outputHashing": "all",
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ]
            }
          },
          "defaultConfiguration": "development"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "challenge-submission:build:production"
            },
            "development": {
              "browserTarget": "challenge-submission:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "challenge-submission:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        }
      }
    }
  }
}

And in my package.json scripts, I have:

"build:challenge-submission:dev": "ng build challenge-submission --configuration=development --output-hashing none && node build-component.js",
"build:challenge-submission:prod": "ng build challenge-submission --configuration=production --output-hashing none && node build-component.js",

As you can see in my angular.json, when I am in the development configuration, it should replace environment.ts with environment.dev.ts, and when in production, it should replace environment.ts with environment.prod.ts.

Weirdly, whichever of the scripts I run, the environment.prod.ts file is being used.

Does anyone have any clue what might be going on?

Thanks!

0

There are 0 best solutions below