feat: show version in dev panel

This commit is contained in:
Tomáš Mládek 2022-07-26 19:43:55 +02:00
parent 637eaa7f55
commit d6e02406d8
3 changed files with 26 additions and 4 deletions

View file

@ -544,10 +544,18 @@
<div> <div>
<span>Zoom level:</span><span>{Math.round(bbox.z * 1000) / 1000}</span> <span>Zoom level:</span><span>{Math.round(bbox.z * 1000) / 1000}</span>
</div> </div>
<label <div>
><input bind:checked={showInternal} type="checkbox" />Show internal <label>
elements</label <input bind:checked={showInternal} type="checkbox" />
> Show internal elements
</label>
</div>
<div>
<!-- svelte-ignore missing-declaration -->
<p class="version">
Version - {__COMMIT_HASH__}
</p>
</div>
</div> </div>
</div> </div>
@ -598,6 +606,13 @@
border: 2px solid white; border: 2px solid white;
font-family: monospace; font-family: monospace;
padding: 1em 2em; padding: 1em 2em;
.version {
text-align: center;
font-weight: bold;
width: 100%;
margin: 0.5em;
}
} }
.devpanel div { .devpanel div {

1
src/vite-env.d.ts vendored
View file

@ -1,2 +1,3 @@
/// <reference types="svelte" /> /// <reference types="svelte" />
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare const __COMMIT_HASH__: string

View file

@ -1,8 +1,14 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte"; 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/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [svelte()], plugins: [svelte()],
base: "", base: "",
define: {
__COMMIT_HASH__: JSON.stringify(commitHash),
},
}); });