add version info and commit date info from git

This commit is contained in:
kerms 2024-04-01 16:22:28 +08:00
parent c7d1dff0d0
commit 63e1e1c5f3
3 changed files with 9 additions and 6 deletions

View File

@ -4,11 +4,11 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": ". ./set_env.sh && vite",
"build": "run-p type-check \"build-only {@}\" --", "build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview", "preview": ". ./set_env.sh && vite preview",
"build-only": "vite build", "build-only": ". ./set_env.sh && vite build",
"build:dev": "vite build --mode development", "build:dev": ". ./set_env.sh && vite build --mode development",
"type-check": "vue-tsc --build --force", "type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/" "format": "prettier --write src/"

3
set_env.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
export VITE_APP_GIT_TAG=$(git describe --tags)
export VITE_APP_LAST_COMMIT=$(git log -1 --format=%cd)

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
const version = __APP_VERSION__; const version = import.meta.env.VITE_APP_GIT_TAG;
const compileTime = __BUILD_TIME__; const compileTime = import.meta.env.VITE_APP_LAST_COMMIT;
</script> </script>
<template> <template>