Issue
I have a working angular application with few dependencies in it. It's Package.json is
{
"name": "ngrx-poc",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 4202",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.1.0",
"@angular/common": "~13.1.0",
"@angular/compiler": "~13.1.0",
"@angular/core": "~13.1.0",
"@angular/forms": "~13.1.0",
"@angular/localize": "~13.1.0",
"@angular/platform-browser": "~13.1.0",
"@angular/platform-browser-dynamic": "~13.1.0",
"@angular/router": "~13.1.0",
"@lottiefiles/lottie-player": "^1.5.6",
"@ng-bootstrap/ng-bootstrap": "^12.0.0",
"@ngrx/store": "^13.0.2",
"@popperjs/core": "^2.10.2",
"apexcharts": "^3.33.2",
"bootstrap": "^5.1.3",
"lottie-web": "^5.9.1",
"ng-apexcharts": "^1.7.0",
"ng-otp-input": "^1.8.5",
"ngx-lottie": "^8.0.1",
"ngx-toastr": "^14.2.1",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.1.2",
"@angular/cli": "~13.1.2",
"@angular/compiler-cli": "~13.1.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.5.2"
}
}
Now, I want to add custom field in package.json
named as build_version ex
"build_version" : "2022-04-13T08:20:47.990Z"
This property should be added in package.json on build time. i.e. when I will use ng build --prod
Can I do this ? If yes how ?
Solution
I have tried modifying the package.json
using a replace-in-file.
But, it won't work with angular (or more specifically in browser) and the maintainer is also insisting the same.
https://github.com/adamreisnz/replace-in-file/issues/154#issue-1203080403
Hence, I have used this and worked perfectly for me.
Answered By - sudarshan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.