-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnext.config.ts
More file actions
30 lines (26 loc) · 899 Bytes
/
next.config.ts
File metadata and controls
30 lines (26 loc) · 899 Bytes
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
import type { NextConfig } from "next";
/**
* GitHub Pages project URL is https://<org>.github.io/<repo>/, which needs
* basePath `/<repo>`. A custom apex domain (e.g. steem.com) is served from `/`,
* so the same basePath would produce `steem.com/steem.com/...` for assets.
* Use NEXT_PUBLIC_BASE_PATH only when you must serve the github.io project URL;
* leave unset or empty for a custom domain at the site root.
*/
function basePathFromEnv(): string | undefined {
const raw = process.env.NEXT_PUBLIC_BASE_PATH?.trim();
if (!raw || raw === "/") {
return undefined;
}
return raw.startsWith("/") ? raw : `/${raw}`;
}
const basePath = basePathFromEnv();
const nextConfig: NextConfig = {
output: "export",
distDir: "out",
trailingSlash: true,
...(basePath ? { basePath, assetPrefix: basePath } : {}),
images: {
unoptimized: true,
},
};
export default nextConfig;