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
@@ -24,7 +24,9 @@ export function SettingsPanel() {
|
||||
<div className="panel" onClick={() => setShowSettings(false)}>
|
||||
<div className="panel-inner" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="panel-head">
|
||||
<h2>Settings</h2>
|
||||
<h2>
|
||||
Settings <span className="build-date">{__BUILD_DATE__}</span>
|
||||
</h2>
|
||||
<button className="icon-btn" onClick={() => setShowSettings(false)}>
|
||||
<CloseIcon width={20} height={20} />
|
||||
</button>
|
||||
|
||||
@@ -1087,6 +1087,13 @@ select:focus {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.panel-head .build-date {
|
||||
font-size: 11.5px;
|
||||
font-weight: 400;
|
||||
color: var(--text-faint);
|
||||
margin-left: 6px;
|
||||
}
|
||||
.panel-head .icon-btn {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
/** Injected by `vite.config.ts` via `define` — set to the build/dev-server start time. */
|
||||
declare const __BUILD_DATE__: string;
|
||||
@@ -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