chore(build): automatically embed git commit hash in version string
This commit is contained in:
+9
-1
@@ -1,7 +1,15 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
import { execSync } from 'child_process'
|
||||||
|
|
||||||
const gitSha = process.env.GIT_SHA || 'dev'
|
let gitSha = process.env.GIT_SHA
|
||||||
|
if (!gitSha) {
|
||||||
|
try {
|
||||||
|
gitSha = execSync('git rev-parse --short HEAD').toString().trim()
|
||||||
|
} catch (e) {
|
||||||
|
gitSha = 'dev'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|||||||
Reference in New Issue
Block a user