-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
25 lines (21 loc) · 868 Bytes
/
Copy pathnext.config.ts
File metadata and controls
25 lines (21 loc) · 868 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
import type { NextConfig } from "next";
import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
export default (phase: string, { defaultConfig }: { defaultConfig: NextConfig }): NextConfig => {
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
// Strictly enforce NO basePath and NO static export during local dev
if (isDev) {
return {
images: { unoptimized: true },
};
}
// Production build config (for gh-pages deployment)
const configuredBasePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "/project-universe-";
const normalizedBasePath = configuredBasePath === "/" ? "" : configuredBasePath.replace(/\/+$/, "");
const configuredDistDir = process.env.NEXT_DIST_DIR || ".next";
return {
distDir: configuredDistDir,
output: "export",
basePath: normalizedBasePath || undefined,
images: { unoptimized: true },
};
};