-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathnext.config.static.ts
More file actions
56 lines (48 loc) · 1.34 KB
/
next.config.static.ts
File metadata and controls
56 lines (48 loc) · 1.34 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
47
48
49
50
51
52
53
54
55
56
// import {readFileSync} from "node:fs";
import {fileURLToPath} from "node:url";
import type {NextConfig} from 'next';
import {createMDX} from 'fumadocs-mdx/next';
import {ghPagesUrl, gitConfig} from './src/lib/shared';
const withMDX = createMDX();
const isGitHubPagesBuild =
process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_PAGES === "true"
const isVercelBuild = process.env.VERCEL === "1"
const isLocalBuild = !isGitHubPagesBuild && !isVercelBuild
const resolveBaseUrl = () => {
const publicUrl = process.env.NEXT_PUBLIC_SITE_URL
if (publicUrl !== undefined && publicUrl !== "") {
return publicUrl
}
if (isGitHubPagesBuild) {
return ghPagesUrl;
}
return "http://localhost:3000"
};
const resolveBasePath = () => {
if (isGitHubPagesBuild) {
return `/${gitConfig.repo}`
}
return undefined
};
const config: NextConfig = {
output: 'export',
reactStrictMode: true,
env: {
NEXT_CONFIG: 'static',
NEXT_PUBLIC_BASE_URL: resolveBaseUrl(),
NEXT_PUBLIC_BASE_PATH: resolveBasePath() ?? '',
},
basePath: resolveBasePath(),
turbopack: {
root: fileURLToPath(new URL(".", import.meta.url)),
},
images: { unoptimized: true },
serverExternalPackages: ["typescript"],
...(isLocalBuild ? {
experimental: {
cpus: 4,
workerThreads: false,
},
} : {}),
};
export default withMDX(config);