title: How do I add a version number to a SvelteKit/Vite app?
body: <p>I'm trying to create a system in my SvelteKit app where it shows you info about the current app version (ideally a Git commit hash and description) on a certain page. I tried using <a href="https://vitejs.dev/config/#define" rel="nofollow noreferrer">Vite's define feature</a> to do this at build time but it doesn't seem to work. How do I add something like this?</p>
  <p>Here's an example of what I tried to do:</p>
  <p>Vite config in svelte.config.js</p>
  <pre class="lang-js prettyprint-override"><code>vite: () =&gt; ({
      define: {
          '__APP_VERSION__': JSON.stringify('testfornow')
      }
  })
  </code></pre>
  <p>index.svelte:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script lang=&quot;ts&quot;&gt;
      const version: string = __APP_VERSION__;
  &lt;/script&gt;
  
  &lt;p&gt;Current App version: {version}&lt;/p&gt;
  </code></pre>