Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular build command is not replacing environment files

I am using Angular v6.

My angular.json file has the following configuration

          "test": {
          "fileReplacements": [
            {
              "replace": "./src/environments/environment.ts",
              "with": "./src/environments/environment.test.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "serviceWorker": true
        },

When i run ng build --configuration=test it is not replacing the environment.ts file with environment.test.ts file.

Here is the configuration it added in the main.js file

/***/ "./src/environments/environment.ts":
/*!*****************************************!*\
  !*** ./src/environments/environment.ts ***!
  \*****************************************/
/*! exports provided: environment */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "environment", function() { return environment; });
var environment = {
    production: false,
    buildName: 'development',
}

How to fix this issue?

like image 958
vistej Avatar asked Dec 06 '25 15:12

vistej


1 Answers

Try:

npm run ng build -- --prod
like image 129
user10610452 Avatar answered Dec 08 '25 04:12

user10610452



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!