-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnext.config.js
More file actions
84 lines (77 loc) · 2.52 KB
/
Copy pathnext.config.js
File metadata and controls
84 lines (77 loc) · 2.52 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
const { execSync } = require('child_process')
// Get git info at build time
const getGitInfo = () => {
try {
const commitHash = execSync('git rev-parse --short HEAD').toString().trim()
const commitDate = execSync('git log -1 --format=%ci').toString().trim()
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
return { commitHash, commitDate, branch }
} catch (e) {
return { commitHash: 'unknown', commitDate: '', branch: 'unknown' }
}
}
const gitInfo = getGitInfo()
// For deployments requiring a base path (e.g., username.github.io/repo)
// Set BASE_PATH=/yappr when needed, otherwise defaults to root
const basePath = process.env.BASE_PATH || ''
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath,
assetPrefix: basePath,
trailingSlash: true,
generateBuildId: async () => gitInfo.commitHash,
env: {
NEXT_PUBLIC_GIT_COMMIT_HASH: gitInfo.commitHash,
NEXT_PUBLIC_GIT_COMMIT_DATE: gitInfo.commitDate,
NEXT_PUBLIC_GIT_BRANCH: gitInfo.branch,
// Subpath deployments share the origin with the root deployment, so
// client-side storage keys are namespaced by the base path (lib/storage-scope.ts).
NEXT_PUBLIC_STORAGE_SCOPE: basePath ? basePath.replace(/^\//, '') : '',
},
reactStrictMode: true,
output: 'export',
images: {
unoptimized: true,
domains: ['images.unsplash.com'],
},
webpack: (config, { isServer }) => {
// Optimize EvoSDK bundle size
if (!isServer) {
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
cacheGroups: {
dashevo: {
test: /[\\/]node_modules[\\/]@dashevo[\\/]/,
name: 'evo-sdk',
priority: 10,
reuseExistingChunk: true,
},
},
},
}
}
// Handle WASM files (required for @dashevo/evo-sdk)
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
}
return config
},
async headers() {
return [
{
source: '/:path*',
headers: [
// CSP is set via <meta> tag in app/layout.tsx so it works in static exports.
// CRITICAL: These headers are required for WASM to work
// Using 'credentialless' instead of 'require-corp' to allow cross-origin images
{ key: 'Cross-Origin-Embedder-Policy', value: 'credentialless' },
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
]
}
]
}
}
module.exports = nextConfig