forked from blisstown/campfire
feat: add git commit hash
This commit is contained in:
parent
daaa819e6c
commit
1d4b121ea5
2 changed files with 9 additions and 2 deletions
|
@ -3,11 +3,16 @@ import { defineConfig } from 'vite';
|
|||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import svg from '@poppanator/sveltekit-svg'
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
// get ver from package.json
|
||||
const packageFile = fileURLToPath(new URL('package.json', import.meta.url));
|
||||
const packageData = readFileSync(packageFile, 'utf8');
|
||||
const packageJSON = JSON.parse(packageData);
|
||||
|
||||
// get git commit hash
|
||||
const commitHash = execSync("git rev-parse HEAD")
|
||||
.toString().trim().slice(0, 10)
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
|
@ -15,7 +20,8 @@ export default defineConfig({
|
|||
svg()
|
||||
],
|
||||
define: {
|
||||
APP_VERSION: JSON.stringify(packageJSON.version)
|
||||
APP_VERSION: JSON.stringify(packageJSON.version),
|
||||
APP_COMMIT: `"${commitHash}"`
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue