Angular application version central
Last updated
Last updated
1. Add "prebuild" and "build" in package.json
{
"name": "application",
"version": "1.0.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
<<<<<<<<
<<<<<<<<
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
...
2. Be sure to have included ‘@type/node’ as a dependency in your ‘package.json’ file.
tsconfig.app.json
...
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"types": [
"jasmine",
<<<<<<<<<
]
}
...
3. Add appVersion in environment.ts (‘src\environments\environment.prod.ts’)
export const environment = {
appVersion: require('../../package.json').version + '-dev',
production: false
};
4. default-footer.component.ts
import { environment } from 'src/environments/environment';
currentVersion = environment.appVersion;
5. default-footer.component.html
<span> Version: {{ currentVersion }} </span>
6. npm run build
The application version number will change to "1.0.2"