Last active
August 20, 2019 21:37
-
-
Save ndrake/47e81063795fa8716d7df217cca63803 to your computer and use it in GitHub Desktop.
Insert version from package.json into Ionic 4 page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-header> | |
<ion-toolbar> | |
<ion-buttons slot="start"> | |
<ion-menu-button></ion-menu-button> | |
</ion-buttons> | |
<ion-title>About</ion-title> | |
</ion-toolbar> | |
</ion-header> | |
<ion-content padding> | |
<ion-list> | |
<ion-item> | |
Version @APP_VERSION@ | |
</ion-item> | |
</ion-list> | |
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var git = require('git-rev-sync'); | |
var appVersion = require('../package.json').version; | |
var replace = require('replace-in-file'); | |
module.exports = function(ctx) { | |
const versionString = appVersion + ' (' + git.short() + ')'; | |
console.log('Replacing @APP_VERSION@ with ' + versionString); | |
const options = { | |
files: [ | |
'./www/*.js', | |
'./www/*.js.map' | |
], | |
from: '@APP_VERSION@', | |
to: versionString | |
} | |
try { | |
const result = replace.sync(options); | |
console.log('Changed files: ', result.join(', ')); | |
} catch(error) { | |
console.log('Error doing text replacement: ', error); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "APP_NAME", | |
"integrations": { | |
"cordova": {} | |
}, | |
"type": "angular", | |
"hooks": { | |
"build:after": "./scripts/after_build.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment