forked from nuttyb-community/nuttyb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
46 lines (40 loc) · 1.22 KB
/
Copy pathnext.config.ts
File metadata and controls
46 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { execSync } from 'node:child_process';
import type { NextConfig } from 'next';
/**
* Get the current Git SHA for version tracking.
* Falls back to 'development' if git is unavailable.
*/
function getGitSha(): string {
try {
return execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
} catch {
return 'development';
}
}
/**
* Detect if we're building for GitHub Pages deployment.
* The GITHUB_PAGES env var is set manually in the GitHub Actions workflow.
*/
const isGitHubPages = process.env.GITHUB_PAGES === 'true';
/**
* Base path for GitHub Pages subdirectory deployment.
* Read from NEXT_PUBLIC_BASE_PATH env var (set in deploy.yml).
* Falls back to empty string for development builds.
*/
const basePath = isGitHubPages ? process.env.NEXT_PUBLIC_BASE_PATH || '' : '';
const nextConfig: NextConfig = {
/* config options here */
reactCompiler: true,
env: {
NEXT_PUBLIC_GIT_SHA: getGitSha(),
NEXT_PUBLIC_BASE_PATH: basePath,
},
// Static export for GitHub Pages
output: 'export',
basePath: basePath,
// Disable image optimization (not supported in static export)
images: {
unoptimized: true,
},
};
export default nextConfig;