This commit is contained in:
@@ -1,4 +1,24 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
import { execSync } from 'node:child_process'
|
||||
|
||||
function getGitInfo() {
|
||||
try {
|
||||
const commit = execSync('git rev-parse --short HEAD').toString().trim()
|
||||
const tag = execSync('git describe --tags --abbrev=0').toString().trim()
|
||||
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
|
||||
|
||||
return { commit, tag, branch }
|
||||
} catch {
|
||||
// fallback (production / no .git)
|
||||
return {
|
||||
commit: process.env.NUXT_PUBLIC_GIT_COMMIT || 'unknown',
|
||||
tag: process.env.NUXT_PUBLIC_GIT_TAG || 'no-tag',
|
||||
branch: process.env.NUXT_PUBLIC_GIT_BRANCH || 'unknown'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const git = getGitInfo();
|
||||
|
||||
export default defineNuxtConfig({
|
||||
vite: {
|
||||
optimizeDeps: {
|
||||
@@ -22,7 +42,11 @@ export default defineNuxtConfig({
|
||||
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:5000/api'
|
||||
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:5000/api',
|
||||
gitCommit: git.commit,
|
||||
gitTag: git.tag,
|
||||
gitBranch: git.branch,
|
||||
buildDate: new Date().toISOString(),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user