mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 08:38:37 +00:00
Show Git revision in settings.
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
import { resolve } from 'path'
|
||||
import { readFileSync } from 'fs'
|
||||
import { defineConfig } from 'vite'
|
||||
import preact from '@preact/preset-vite'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
|
||||
function getGitRevision() {
|
||||
try {
|
||||
const rev = readFileSync('.git/HEAD').toString().trim();
|
||||
if (rev.indexOf(':') === -1) {
|
||||
return rev;
|
||||
} else {
|
||||
return readFileSync('.git/' + rev.substring(5)).toString().trim();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to get Git revision.');
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
preact(),
|
||||
@@ -31,6 +46,10 @@ export default defineConfig({
|
||||
]
|
||||
},
|
||||
workbox: { }
|
||||
}),
|
||||
replace({
|
||||
__GIT_REVISION__: getGitRevision(),
|
||||
preventAssignment: true
|
||||
})
|
||||
],
|
||||
build: {
|
||||
|
||||
Reference in New Issue
Block a user