diff --git a/next.config.ts b/next.config.ts
index 954b109..7c80856 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,26 +1,17 @@
import type { NextConfig } from "next";
+import build from "next/dist/build";
+import { describe } from "node:test";
+const nextBuildId = require('next-build-id');
-const generateGitCommitHash = () => {
- if (process.env.NODE_ENV === "development") return "development server";
- if (!process.env.GIT_COMMIT) return "git commit hash is unavailable";
- const hash = process.env.GIT_COMMIT;
- if (!hash || hash.trim().length == 0) return "empty git commit hash";
- return hash;
-}
-
-const gitCommitHash = generateGitCommitHash();
+const buildId = nextBuildId({ dir: __dirname, describe: true })
const nextConfig: NextConfig = {
output: "standalone",
- generateBuildId: () => gitCommitHash,
- webpack: (config, { webpack, buildId, isServer }) => {
- config.plugins.push(
- new webpack.DefinePlugin({
- 'process.env.BUILD_ID_ENV': JSON.stringify(buildId)
- })
- );
- return config;
+ generateBuildId: () => buildId,
+ env: {
+ BUILD_ID: buildId
}
+
};
export default nextConfig;
diff --git a/package-lock.json b/package-lock.json
index e807177..b869ace 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -29,6 +29,7 @@
"dexie-react-hooks": "^1.1.7",
"lucide-react": "^0.525.0",
"next": "^15.4.3",
+ "next-build-id": "^3.0.0",
"next-themes": "^0.4.6",
"react": "19.1.0",
"react-dom": "19.1.0",
@@ -5743,6 +5744,15 @@
}
}
},
+ "node_modules/next-build-id": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/next-build-id/-/next-build-id-3.0.0.tgz",
+ "integrity": "sha512-B3JCsL/9Z/wkmo3EySukQHCgx89Aw0i4LPi2MEhCboQBJ6wpkYTIu1z6hOYKuw/S1Wy8ZRqCEq0dVY/ST6jGqg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/next-themes": {
"version": "0.4.6",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz",
diff --git a/package.json b/package.json
index 2df1ac3..f323628 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"dexie-react-hooks": "^1.1.7",
"lucide-react": "^0.525.0",
"next": "^15.4.3",
+ "next-build-id": "^3.0.0",
"next-themes": "^0.4.6",
"react": "19.1.0",
"react-dom": "19.1.0",
diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx
index f2c817d..733bc7a 100644
--- a/src/app/settings/page.tsx
+++ b/src/app/settings/page.tsx
@@ -9,6 +9,7 @@ import { useIsMobile } from "@/hooks/use-mobile";
import AscendingCard from "@/components/ascending-card";
import Link from "next/link";
import WideContainer from "@/components/wide-container";
+import getBuildID from "@/lib/build";
export default function Settings(): ReactNode {
@@ -46,7 +47,7 @@ export default function Settings(): ReactNode {
Build ID: {process.env.BUILD_ID_ENV}
+Build ID: {getBuildID()}
diff --git a/src/lib/build.ts b/src/lib/build.ts new file mode 100644 index 0000000..760b148 --- /dev/null +++ b/src/lib/build.ts @@ -0,0 +1,5 @@ +const getBuildID = () => ( + process.env.NODE_ENV == "development" ? "development build" : process.env.BUILD_ID +); + +export default getBuildID; \ No newline at end of file