From ca8362d151fb0e10b113a96d90806c29d6f1d174 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Fri, 6 Mar 2026 00:05:25 +0100 Subject: [PATCH] feat: display app version in footer Inject version from package.json at build time via Vite's define and show it in the layout footer. Co-Authored-By: Claude Opus 4.6 --- package.json | 2 +- src/app.d.ts | 2 ++ src/routes/+layout.svelte | 2 +- vite.config.ts | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bfc25c..c218e41 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "crumbs", "private": true, - "version": "0.1.3", + "version": "0.1.4", "type": "module", "scripts": { "dev": "vite dev", diff --git a/src/app.d.ts b/src/app.d.ts index da08e6d..9baa333 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,5 +1,7 @@ // See https://svelte.dev/docs/kit/types#app.d.ts // for information about these interfaces +declare const __APP_VERSION__: string; + declare global { namespace App { // interface Error {} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8da9afc..7f8e329 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -25,7 +25,7 @@
- Crumbs by Bretzel — made with 🥨 in Strasbourg + Crumbs by Bretzel v{__APP_VERSION__} — made with 🥨 in Strasbourg
diff --git a/vite.config.ts b/vite.config.ts index 5c7009d..f3a7955 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,15 @@ +import { readFileSync } from 'node:fs'; import { sveltekit } from '@sveltejs/kit/vite'; import { SvelteKitPWA } from '@vite-pwa/sveltekit'; import tailwindcss from '@tailwindcss/vite'; import { defineConfig } from 'vite'; +const pkg = JSON.parse(readFileSync('package.json', 'utf-8')); + export default defineConfig({ + define: { + __APP_VERSION__: JSON.stringify(pkg.version) + }, plugins: [ tailwindcss(), sveltekit(),