mirror of
https://github.com/revoltchat/revite.git
synced 2025-04-21 15:57:38 -05:00
Show Git revision in settings.
This commit is contained in:
parent
feaec3f8d9
commit
c52f1f5bca
6 changed files with 34 additions and 2 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue