Repository navigation
Expand file tree
/
Copy pathnext.config.mjs
More file actions
85 lines (82 loc) · 3.33 KB
/
Copy pathnext.config.mjs
File metadata and controls
85 lines (82 loc) · 3.33 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
import { createMDX } from 'fumadocs-mdx/next';
import flutterLegacyRedirectAliases from './data/structure/flutter-legacy-redirect-aliases.json' with { type: 'json' };
import flutterSidebar from './data/structure/flutter-sidebar.json' with { type: 'json' };
import harmonyLegacyRedirectAliases from './data/structure/harmony-legacy-redirect-aliases.json' with { type: 'json' };
import harmonySidebar from './data/structure/harmony-sidebar.json' with { type: 'json' };
import iosLegacyRedirectAliases from './data/structure/ios-legacy-redirect-aliases.json' with { type: 'json' };
import iosSidebar from './data/structure/ios-sidebar.json' with { type: 'json' };
import wasmLegacyRedirectEntries from './data/structure/wasm-legacy-redirects.json' with { type: 'json' };
import { buildClientSdkLegacyRedirects } from './scripts/lib/client-sdk-legacy-redirects.mjs';
import { buildWasmLegacyRedirects } from './scripts/lib/wasm-legacy-redirects.mjs';
const deploymentVersion = process.env.DEPLOYMENT_VERSION?.trim();
/** @type {import('next').NextConfig} */
const nextConfig = {
// Keep standalone for Docker/self-host; Vercel uses its managed Next.js runtime.
...(process.env.VERCEL ? {} : { output: 'standalone' }),
...(deploymentVersion
? {
deploymentId: deploymentVersion,
generateBuildId: async () => deploymentVersion,
}
: {}),
distDir: process.env.NODE_ENV === 'development' ? '.next-local' : '.next',
poweredByHeader: false,
reactStrictMode: true,
allowedDevOrigins: ['127.0.0.1'],
// `pnpm check` performs strict TypeScript validation. Skipping the duplicate
// Next.js build-time pass avoids reparsing the dynamic MDX manifest.
typescript: { ignoreBuildErrors: true },
outputFileTracingIncludes: {
'/docs/[[...slug]]': ['./content/docs/**/*.mdx'],
'/docs/guides/[...slug]': [
'./content/zh/docs/guides/**/*.mdx',
'./content/en/docs/guides/**/*.mdx',
],
'/[locale]/docs/guides/[...slug]': [
'./content/zh/docs/guides/**/*.mdx',
'./content/en/docs/guides/**/*.mdx',
],
},
serverExternalPackages: ['shiki'],
images: {
formats: ['image/avif', 'image/webp'],
},
async redirects() {
return [
...buildWasmLegacyRedirects(wasmLegacyRedirectEntries),
...buildClientSdkLegacyRedirects({
platformId: 'ios',
sidebar: iosSidebar,
wasmEntries: wasmLegacyRedirectEntries,
aliases: iosLegacyRedirectAliases,
}),
...buildClientSdkLegacyRedirects({
platformId: 'flutter',
sidebar: flutterSidebar,
wasmEntries: wasmLegacyRedirectEntries,
aliases: flutterLegacyRedirectAliases,
}),
...buildClientSdkLegacyRedirects({
platformId: 'harmony',
sidebar: harmonySidebar,
wasmEntries: wasmLegacyRedirectEntries,
aliases: harmonyLegacyRedirectAliases,
}),
];
},
async headers() {
return [
{
source: '/:path*',
headers: [
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
],
},
];
},
};
const withMDX = createMDX({ outDir: '.source-local' });
export default withMDX(nextConfig);