From d6e02406d8306ac69fba51a67c3904af1a4f23b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Tue, 26 Jul 2022 19:43:55 +0200 Subject: [PATCH] feat: show version in dev panel --- src/components/SVGContent.svelte | 23 +++++++++++++++++++---- src/vite-env.d.ts | 1 + vite.config.ts | 6 ++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/SVGContent.svelte b/src/components/SVGContent.svelte index 7e8b6db..e8f110f 100644 --- a/src/components/SVGContent.svelte +++ b/src/components/SVGContent.svelte @@ -544,10 +544,18 @@
Zoom level:{Math.round(bbox.z * 1000) / 1000}
- +
+ +
+
+ +

+ Version - {__COMMIT_HASH__} +

+
@@ -598,6 +606,13 @@ border: 2px solid white; font-family: monospace; padding: 1em 2em; + + .version { + text-align: center; + font-weight: bold; + width: 100%; + margin: 0.5em; + } } .devpanel div { diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 4078e74..101ec8a 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,2 +1,3 @@ /// /// +declare const __COMMIT_HASH__: string \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 1599316..dbb23dc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,14 @@ import { defineConfig } from "vite"; import { svelte } from "@sveltejs/vite-plugin-svelte"; +import cp from "child_process"; + +const commitHash = cp.execSync("git rev-parse --short HEAD").toString(); // https://vitejs.dev/config/ export default defineConfig({ plugins: [svelte()], base: "", + define: { + __COMMIT_HASH__: JSON.stringify(commitHash), + }, });