diff --git a/src/index.ts b/src/index.ts index ece36f9..84dca6e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -181,3 +181,10 @@ async function init() { } document.addEventListener("DOMContentLoaded", () => initOnce()); + +console.log( + `%c Matecho %c By Zapic \n`, + "color: #fff; background: #E91E63; padding:5px 0;", + "background: #efefef; padding:5px 0;", + `${__BUILD_COMMIT_ID__} @ ${__BUILD_DATE__} ` +); diff --git a/src/matecho.d.ts b/src/matecho.d.ts index a1a9796..738d0e1 100644 --- a/src/matecho.d.ts +++ b/src/matecho.d.ts @@ -32,3 +32,6 @@ declare global { declare interface Window { __MATECHO_ANTI_SPAM__: string; } + +declare const __BUILD_DATE__: string; +declare const __BUILD_COMMIT_ID__: string; diff --git a/vite.config.ts b/vite.config.ts index 2cb47ea..7d87f35 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,9 +4,21 @@ import fg from "fast-glob"; import Matecho from "./plugins/Matecho"; import PrismJS from "./plugins/Prism"; import UnoCSSClassMangle from "./plugins/UnoCSSClassMangle"; +import fs from "node:fs"; export default defineConfig(async env => { const isProd = env.mode === "production"; + let COMMIT_ID = "unknown"; + try { + const id = fs + .readFileSync(__dirname + "/.git/HEAD") + .toString("utf-8") + .trim(); + console.log("Current head @ " + id); + COMMIT_ID = id.startsWith("ref:") ? id : id.substring(0, 7); + } catch (_) { + /**/ + } return { plugins: [ @@ -52,6 +64,10 @@ export default defineConfig(async env => { minify: isProd, cssMinify: isProd }, + define: { + __BUILD_DATE__: JSON.stringify(new Date().toString()), + __BUILD_COMMIT_ID__: JSON.stringify(COMMIT_ID) + }, base: "/__VIRTUAL_THEME_ROOT__" } as UserConfig; });