Show build date next to "Settings" heading
Inject a yyyy-mm-dd_hh:mm timestamp at build time via Vite's `define` (app/vite.config.ts: __BUILD_DATE__, computed fresh on every `vite build`/`vite dev` invocation) and render it next to the Settings panel's title, so it's easy to tell which build is deployed. - app/vite.config.ts: buildDateString() + define.__BUILD_DATE__ - app/src/vite-env.d.ts: ambient declaration for the injected constant - app/src/components/SettingsPanel.tsx: render it next to "Settings" - app/src/styles.css: .build-date styling Rebuilt and redeployed to the repo root.
This commit is contained in:
1 parent
ea1aeed1da
commit
b2bee03ca2
8 files changed
+29
-6
No files matched your search
@@ -4,6 +4,13 @@ import { defineConfig, loadEnv, type Plugin } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
|
||||
/** `yyyy-mm-dd_hh:mm` timestamp of this build/dev-server start, shown in the UI. */
|
||||
function buildDateString(): string {
|
||||
const d = new Date();
|
||||
const pad = (n: number) => String(n).padStart(2, "0");
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}_${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
/** Emits the repo's LICENSE file into the build output. */
|
||||
function licensePlugin(): Plugin {
|
||||
return {
|
||||
@@ -27,6 +34,9 @@ export default defineConfig(({ mode }) => {
|
||||
const target = env.HERMES_DEV_TARGET;
|
||||
|
||||
return {
|
||||
define: {
|
||||
__BUILD_DATE__: JSON.stringify(buildDateString()),
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: target
|
||||
|
||||
Reference in new issue
Block a user