'nx lib responsible for environment fileReplacements not working

  • I have this lib, @my-proj/common which export * from './lib/environment'; in its index.ts
  • my frontend (ng) and backend(express // nest) apps import { environment } from '@my-proj/common';
  • when I build these apps only dev vars are used. ie npx nx build angular-app --prod;
  • I thought since I was building with the prod flag it would use environment.prod.ts from @my-proj/common ?

Project configuration:

"common": {
  "root": "libs/common",
  "sourceRoot": "libs/common/src",
  "projectType": "library",
  "architect": {
    "build": {
      "builder": "@nrwl/node:package",
      "outputs": ["{options.outputPath}"],
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "libs/common/src/lib/environment.ts",
              "with": "libs/common/src/lib/environment.prod.ts"
            }
          ]
        }
      },
      "options": {
        "outputPath": "dist/libs/common",
        "tsConfig": "libs/common/tsconfig.lib.json",
        "packageJson": "libs/common/package.json",
        "main": "libs/common/src/index.ts",
        "assets": ["libs/common/*.md"]
      }
    }
  },
  "tags": []
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source