mirror of
https://github.com/ClipFusion-org/clipfusion.git
synced 2025-08-05 14:45:08 +00:00
integrated next-build-id library
This commit is contained in:
parent
ad39e0d557
commit
10ad436c92
@ -1,26 +1,17 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
import build from "next/dist/build";
|
||||||
|
import { describe } from "node:test";
|
||||||
|
const nextBuildId = require('next-build-id');
|
||||||
|
|
||||||
const generateGitCommitHash = () => {
|
const buildId = nextBuildId({ dir: __dirname, describe: true })
|
||||||
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 nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
generateBuildId: () => gitCommitHash,
|
generateBuildId: () => buildId,
|
||||||
webpack: (config, { webpack, buildId, isServer }) => {
|
env: {
|
||||||
config.plugins.push(
|
BUILD_ID: buildId
|
||||||
new webpack.DefinePlugin({
|
|
||||||
'process.env.BUILD_ID_ENV': JSON.stringify(buildId)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
10
package-lock.json
generated
10
package-lock.json
generated
@ -29,6 +29,7 @@
|
|||||||
"dexie-react-hooks": "^1.1.7",
|
"dexie-react-hooks": "^1.1.7",
|
||||||
"lucide-react": "^0.525.0",
|
"lucide-react": "^0.525.0",
|
||||||
"next": "^15.4.3",
|
"next": "^15.4.3",
|
||||||
|
"next-build-id": "^3.0.0",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "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": {
|
"node_modules/next-themes": {
|
||||||
"version": "0.4.6",
|
"version": "0.4.6",
|
||||||
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz",
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
"dexie-react-hooks": "^1.1.7",
|
"dexie-react-hooks": "^1.1.7",
|
||||||
"lucide-react": "^0.525.0",
|
"lucide-react": "^0.525.0",
|
||||||
"next": "^15.4.3",
|
"next": "^15.4.3",
|
||||||
|
"next-build-id": "^3.0.0",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.1.0",
|
"react-dom": "19.1.0",
|
||||||
|
@ -9,6 +9,7 @@ import { useIsMobile } from "@/hooks/use-mobile";
|
|||||||
import AscendingCard from "@/components/ascending-card";
|
import AscendingCard from "@/components/ascending-card";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import WideContainer from "@/components/wide-container";
|
import WideContainer from "@/components/wide-container";
|
||||||
|
import getBuildID from "@/lib/build";
|
||||||
|
|
||||||
|
|
||||||
export default function Settings(): ReactNode {
|
export default function Settings(): ReactNode {
|
||||||
@ -46,7 +47,7 @@ export default function Settings(): ReactNode {
|
|||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
</AscendingCard>
|
</AscendingCard>
|
||||||
</Link>
|
</Link>
|
||||||
<p className="text-sm text-muted-foreground">Build ID: {process.env.BUILD_ID_ENV}</p>
|
<p className="text-sm text-muted-foreground">Build ID: {getBuildID()}</p>
|
||||||
</div>
|
</div>
|
||||||
</WideContainer>
|
</WideContainer>
|
||||||
</div>
|
</div>
|
||||||
|
5
src/lib/build.ts
Normal file
5
src/lib/build.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const getBuildID = () => (
|
||||||
|
process.env.NODE_ENV == "development" ? "development build" : process.env.BUILD_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
export default getBuildID;
|
Loading…
Reference in New Issue
Block a user