Skip to content

Commit 3aaa004

Browse files
authored
Pass TIMESTAMP and GIT_VERSION from Astro config. (#1184)
1 parent e730a80 commit 3aaa004

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

astro.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ import metaTags from "astro-meta-tags";
1111
import pagefind from "astro-pagefind";
1212
import deleteUnusedImages from "astro-delete-unused-images";
1313
import preload from "astro-preload";
14+
import { execSync } from "node:child_process";
1415

1516
// https://astro.build/config
1617
export default defineConfig({
1718
vite: {
1819
define: {
19-
"process.env.VITE_BUILD_TIME": JSON.stringify(new Date().toISOString()),
20+
"import.meta.env.TIMESTAMP": new Date()
21+
.toISOString()
22+
.replace(/[-:T.Z]/g, "")
23+
.slice(0, 14),
24+
"import.meta.env.GIT_VERSION": new String(
25+
execSync("git rev-parse --short HEAD")
26+
),
2027
},
2128
resolve: {
2229
alias: {

0 commit comments

Comments
 (0)