campfire/vite.config.js

27 lines
766 B
JavaScript

import { sveltekit } from '@sveltejs/kit/vite';
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: [
sveltekit(),
svg()
],
define: {
APP_VERSION: JSON.stringify(packageJSON.version),
APP_COMMIT: `"${commitHash}"`
}
});