when I run the "ng build" command in a terminal, it builds the development environment, not the production environment.
If I run the "ng build --prod" it works fine. But without changing any default behavior, it is building the development environment.
If I run the "npm run build" command it correctly builds the production environment.
I want to know why this happens and how to fix this? I have provided the package.json and angular.json files below:
Package.json:
{
"name": "xxx",
"version": "1.0.0",
"description": "..........",
"license": "MIT",
"scripts": {
"ng": "ng",
"postinstall": "ngcc --properties es2015 browser module main --first-only",
"start": "ng serve",
"build": "ng build --prod --aot --build-optimizer --common-chunk --vendor-chunk --optimization --progress",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"prettier": "prettier --write \"{,!(node_modules|dist|build|coverage)/**/}*.{js,jsx,ts,json}\"",
"pre-commit": "npm run lint && npm run prettier",
"extract-i18n": "ngx-translate-extract --input ./src --output ./src/assets/i18n/{en,nl,fr,es,it,de}.json --format namespaced-json --sort"
},
"private": true,
"husky": {
"hooks": {
"pre-commit": "npm run pre-commit"
}
},
"dependencies": {
"@angular/animations": "^11.1.0",
"@angular/cdk": "^11.1.0",
"@angular/common": "^11.1.0",
"@angular/compiler": "^11.1.0",
"@angular/core": "^11.1.0",
"@angular/forms": "^11.1.0",
"@angular/localize": "^11.1.0",
"@angular/platform-browser": "^11.1.0",
"@angular/platform-browser-dynamic": "^11.1.0",
"@angular/router": "^11.1.0",
"@coreui/angular": "~2.11.1",
"@coreui/coreui": "^2.1.16",
"@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
"@coreui/icons": "^2.0.0-rc.0",
"@coreui/icons-angular": "1.0.0-alpha.3",
"@fortawesome/angular-fontawesome": "^0.8.2",
"@fortawesome/fontawesome-svg-core": "^1.2.34",
"@fortawesome/free-brands-svg-icons": "^5.15.2",
"@fortawesome/free-regular-svg-icons": "^5.15.2",
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@ng-select/ng-select": "^6.1.0",
"@ngrx/store": "^11.0.1",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@rxweb/reactive-form-validators": "^2.1.2",
"@uiowa/digit-only": "^2.2.3",
"ag-grid-angular": "^25.1.0",
"ag-grid-community": "^25.1.0",
"bootstrap": "^4.6.0",
"bs-stepper": "^1.7.0",
"chart.js": "^2.9.4",
"classlist.js": "^1.1.20150312",
"cookieconsent": "^3.1.1",
"core-js": "^3.8.3",
"lodash": "^4.17.21",
"messageformat": "^2.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.37",
"ng-lazyload-image": "^9.1.0",
"ngrx-store-localstorage": "^11.0.0",
"ngx-avatar": "^4.1.0",
"ngx-bootstrap": "^6.2.0",
"ngx-cookieconsent": "^2.2.3",
"ngx-editor": "^9.0.2",
"ngx-perfect-scrollbar": "^10.1.0",
"ngx-toastr": "^13.2.1",
"ngx-translate-cache": "^9.0.2",
"ngx-translate-messageformat-compiler": "^4.9.0",
"primeflex": "^2.0.0",
"primeicons": "^4.1.0",
"primeng": "^11.2.3",
"rxjs": "^6.6.3",
"simple-line-icons": "^2.5.5",
"ts-helpers": "^1.1.2",
"tslib": "^2.0.0",
"web-animations-js": "^2.3.2",
"xlsx": "^0.18.5",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1101.1",
"@angular/cli": "^11.1.1",
"@angular/compiler-cli": "^11.1.0",
"@angular/language-service": "^11.1.0",
"@biesbjerg/ngx-translate-extract": "^7.0.3",
"@types/jasmine": "^3.6.3",
"@types/jasminewd2": "^2.0.8",
"@types/lodash": "^4.14.184",
"@types/node": "^14.14.22",
"codelyzer": "^6.0.0",
"husky": "^5.1.2",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.2.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"prettier": "^2.2.1",
"protractor": "~7.0.0",
"ts-node": "^8.10.2",
"tslint": "~6.1.0",
"typescript": "~4.0.5"
},
"engines": {
"node": ">= 10.13",
"npm": "= 6.11.0"
}
}
angular.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": ["src/assets", "src/assets/i18n"],
"styles": [
"node_modules/@coreui/icons/css/free.css",
"node_modules/simple-line-icons/dist/styles/simple-line-icons.css",
"src/scss/style.scss",
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/themes/saga-blue/theme.css",
"node_modules/primeng/resources/primeng.min.css",
"node_modules/cookieconsent/build/cookieconsent.min.css",
"node_modules/ngx-bootstrap/datepicker/bs-datepicker.css"
],
"stylePreprocessorOptions": {
"includePaths": ["./node_modules", "src/scss"]
},
"scripts": ["node_modules/cookieconsent/build/cookieconsent.min.js"],
"allowedCommonJsDependencies": ["lodash"]
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ng:build"
},
"configurations": {
"production": {
"browserTarget": "ng:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"node_modules/@coreui/icons/css/free.css",
"node_modules/simple-line-icons/dist/styles/simple-line-icons.css",
"src/scss/style.scss"
],
"stylePreprocessorOptions": {
"includePaths": ["./node_modules"]
},
"assets": ["src/assets", "src/favicon.ico"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ng-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "ng:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["e2e/tsconfig.e2e.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "ng",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"style": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
},
"cli": {
"analytics": false
}
}