Closed stared closed 4 years ago
I want to make it easier to see which version we display. Right now it works that way:
Looking at how to add the release date, as it may be more informative than version (or hash).
@KlemKlem - obviously style is temporary, so feel invited to change it in any way you like.
I didn't try to deploy it yet. Since these are build-related things, it make work or not.
It took me quite a lot of time to figure out how to include hash commits. In the end, I use git-describe, see vue.config.js.
vue.config.js
I did try:
Works, but code seems extraneous. vue.config.js would look like (example from: https://forum.vuejs.org/t/trying-to-add-gitrevisionplugin-to-cli-3/65567):
const GitRevisionPlugin = require('git-revision-webpack-plugin') module.exports = { 'chainWebpack': config => { config.plugin('define').tap(args => { const gitRevisionPlugin = new GitRevisionPlugin() args[0]['process.env']['VUE_APP_COMMIT_HASH'] = JSON.stringify(gitRevisionPlugin.commithash()) return args }) } }
Package not maintained (only a single release) + variables in the global space (problems with linters).
.env
assets
git log -n 1 --pretty=format:"VUE_APP_GIT_HASH=%h%nVUE_APP_GIT_DATE=%aD" >> .env
But had some issues with reading .env variables. Similarly, one can create a JSON asset and load it from there. It might be a not that bad idea (just one need to add extra scripts in package.json so to generate these files, always when building).
package.json
I want to make it easier to see which version we display. Right now it works that way:
Looking at how to add the release date, as it may be more informative than version (or hash).
@KlemKlem - obviously style is temporary, so feel invited to change it in any way you like.
I didn't try to deploy it yet. Since these are build-related things, it make work or not.
Notes
It took me quite a lot of time to figure out how to include hash commits. In the end, I use git-describe, see
vue.config.js
.I did try:
git-revision-webpack-plugin
Works, but code seems extraneous.
vue.config.js
would look like (example from: https://forum.vuejs.org/t/trying-to-add-gitrevisionplugin-to-cli-3/65567):vue-cli-plugin-git-describe
Package not maintained (only a single release) + variables in the global space (problems with linters).
.env
orassets
git log -n 1 --pretty=format:"VUE_APP_GIT_HASH=%h%nVUE_APP_GIT_DATE=%aD" >> .env
But had some issues with reading
.env
variables. Similarly, one can create a JSON asset and load it from there. It might be a not that bad idea (just one need to add extra scripts inpackage.json
so to generate these files, always when building).See also: