-
Notifications
You must be signed in to change notification settings - Fork 46
/
next.config.js
59 lines (54 loc) · 1.44 KB
/
next.config.js
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
/** @type {import('next').NextConfig} */
const {execSync} = require("node:child_process");
let gitSha = undefined,
gitShaShort = "unknown",
gitDirty = "false";
try {
gitSha = execSync("git rev-parse HEAD", { windowsHide: true }).toString().trim();
gitShaShort = execSync("git rev-parse --short HEAD", { windowsHide: true }).toString().trim();
gitDirty = execSync("git status --untracked-files=no --porcelain", { windowsHide: true }).toString().trim();
if (gitDirty !== "") {
gitDirty = "true";
}
} catch (e) {
console.warn(`No git data available, building without`);
}
const shouldAnalyse = process.env.ANALYSE === 'true';
let nextConfig = {
output: 'export',
reactStrictMode: true,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
images: {
unoptimized: true,
domains: ['runescape.wiki', 'oldschool.runescape.wiki'],
},
transpilePackages: [
'd3',
'd3-array',
'internmap'
],
env: {
GIT_SHA: gitSha,
GIT_SHA_SHORT: gitShaShort,
GIT_DIRTY: gitDirty,
},
async redirects() {
if (process.env.NEXT_PUBLIC_BASE_PATH) {
return [
{
source: '/',
destination: process.env.NEXT_PUBLIC_BASE_PATH,
basePath: false,
permanent: true
}
]
} else {
return [];
}
}
}
if (shouldAnalyse) {
const withNextBundleAnalyzer = require('@next/bundle-analyzer')();
nextConfig = withNextBundleAnalyzer(nextConfig);
}
module.exports = nextConfig