Skip to content

Commit

Permalink
🔨 improve version retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
devmount committed Sep 18, 2020
1 parent 5ee1057 commit ac6d859
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"@vue/cli-service": "^3.0.0-beta.15",
"vue-template-compiler": "^2.5.16"
},
"vue": {
"publicPath": "/"
},
"babel": {
"presets": [
"@vue/app"
Expand Down
8 changes: 5 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<a href="https://twitter.com/intent/tweet?text=Awesome%20little%20app%20to%20help%20quitting%20with%20a%20bad%20habit%20%F0%9F%98%8E&url=https%3A%2F%2Fyoucanqu.it&via=devmount&hashtags=ycq%2Cvuejs%2CDEVcommunity" target="_blank"><font-awesome-icon :icon="['fab', 'twitter']" class="icon" /></a>
<a href="https://dev.to/devmount/you-can-quit-with-the-help-of-vue-and-dexie-221i" target="_blank"><font-awesome-icon :icon="['fab', 'dev']" class="icon" /></a>
</div>
<div class="mt-2">{{ $t('version') }} {{ version }}</div>
<div class="mt-2">{{ $t('version') }} {{ appVersion }}</div>
<div> with 🤍 by <a href="https://devmount.de" target="_blank">devmount</a></div>
</footer>
<notifications group="main" position="bottom right"/>
Expand Down Expand Up @@ -94,7 +94,6 @@ export default {
data () {
// today
var now = new Date()
let version = require('../package.json').version
return {
date: {
month: now.getMonth()+1,
Expand All @@ -107,7 +106,6 @@ export default {
year: now.getFullYear(),
},
data: {},
version: version
}
},
created () {
Expand Down Expand Up @@ -245,6 +243,10 @@ export default {
}
},
computed: {
// return current app version from package.json
appVersion() {
return process.env.PACKAGE_VERSION;
},
// compute the number of days of the month currently displayed
daysInMonth () {
return new Date(this.date.year, this.date.month, 0).getDate();
Expand Down
19 changes: 19 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const webpack = require('webpack')
const fs = require('fs')
const packageJson = fs.readFileSync('./package.json')
const version = JSON.parse(packageJson).version || 0

module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
'process.env': {
PACKAGE_VERSION: '"' + version + '"'
}
})
]
},
publicPath: '/',
chainWebpack: config => config.plugins.delete('named-chunks'),
parallel: false
}

0 comments on commit ac6d859

Please sign in to comment.