-
Notifications
You must be signed in to change notification settings - Fork 13
/
next.config.mjs
94 lines (88 loc) · 2.8 KB
/
next.config.mjs
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
90
91
92
93
94
import bundleAnalyzer from "@next/bundle-analyzer";
import { loadConfig } from "./.build/server/config-site.mjs";
import { getRedirects } from "./.build/server/paths.mjs";
import { securityHeaders } from "./server/headers.mjs";
import { deprecatedVersionRedirects } from "./server/redirects/redirects.mjs";
import { resolve } from "path";
import {
generateEvent,
generateNavigation,
} from "./.build/server/sanity-settings.mjs";
const publicRoot = resolve("public");
/*=========================================================
Generate event file
=========================================================*/
generateEvent({
file: resolve(publicRoot + "/data/", "events.json"),
});
/*=========================================================
Get navigation settings
=========================================================*/
generateNavigation({
file: resolve(publicRoot + "/data/", "navbar.json"),
});
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === "true",
});
const { latest } = loadConfig();
export default withBundleAnalyzer({
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
basePath: "/docs",
transpilePackages: ["@inkeep/widgets", "react-syntax-highlighter"],
redirects: async () => [
...deprecatedVersionRedirects,
...getRedirects(),
{
source: `/ver/${latest}/:path*`,
destination: "/:path*",
permanent: false,
},
],
headers: async () => [
{
source: "/:path*",
headers: securityHeaders,
},
],
images: {
path: "/docs/_next/image",
disableStaticImages: true,
domains: ["i.ytimg.com", "goteleport.com", "cdn.sanity.io"], // Images for youtube preview, goteleport.com for featured resource
},
trailingSlash: true,
env: {
DOCS_LATEST_VERSION: latest,
},
webpack: (config) => {
config.module.rules.push({
test: /\.(png|jpg|webp|gif|mp4|webm|ogg|swf|ogv|woff2)$/i,
type: "asset/resource",
});
config.module.rules.push({
test: /\.svg$/,
oneOf: [
{
issuer: /\.[mjt]sx?$/,
resourceQuery: /react/,
use: "@svgr/webpack",
},
{
type: "asset/resource",
},
],
});
return config;
},
// This line will remove docs pages and images from @vercel/nft results.
// Without it docs will not build because of serverless function size errors.
// Right now it disables everything, but if we want to enable incremental builds
// we may want to remove mdx pages and code examples from the flag.
// It will also require manually moving image files to public folder before next build,
// becase if we move them as a part of build size of image folder will also cause
// serverless function limit problem.
experimental: {
outputFileTracingExcludes: {
"/[[...slug]]": ["**/*"],
},
},
});