-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
89 lines (85 loc) · 2.24 KB
/
Copy pathnext.config.ts
File metadata and controls
89 lines (85 loc) · 2.24 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type { NextConfig } from "next";
const isGitHubPages = process.env.GITHUB_PAGES === 'true';
const configuredBasePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
// If deploying to GitHub Pages, default basePath to "/<repo>" when not provided
const inferredRepoName = process.env.GITHUB_REPOSITORY?.split('/')?.[1] ?? '';
const basePath = configuredBasePath || (isGitHubPages && inferredRepoName ? `/${inferredRepoName}` : '');
const nextConfig: NextConfig = {
// Enable static export when targeting GitHub Pages
...(isGitHubPages
? {
output: 'export',
trailingSlash: true,
basePath,
assetPrefix: basePath || undefined,
}
: {}),
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
outputFileTracingRoot: __dirname,
experimental: {
turbo: {
resolveAlias: {
// Prevent file system race conditions
'~': __dirname,
},
},
},
images: {
// Images must be unoptimized for static exports on GitHub Pages
...(isGitHubPages ? { unoptimized: true } : {}),
remotePatterns: [
{
protocol: 'https',
hostname: 'images.unsplash.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'github.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'raw.githubusercontent.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'cdn.shopify.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'www.angeljackets.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'res.cloudinary.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'i.etsystatic.com',
port: '',
pathname: '/**',
},
// Optional: user-provided CDN
...(process.env.NEXT_PUBLIC_IMAGE_CDN
? [{ protocol: 'https', hostname: process.env.NEXT_PUBLIC_IMAGE_CDN.replace(/^https?:\/\//, '').split('/')[0], port: '', pathname: '/**' } as const]
: []),
],
},
};
export default nextConfig;