-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
128 lines (115 loc) · 3.03 KB
/
Copy pathnext.config.js
File metadata and controls
128 lines (115 loc) · 3.03 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const redirects = require("./content/settings/config.json")?.redirects || [];
/** @type {import('next').NextConfig} */
const isStatic = process.env.EXPORT_MODE === "static";
const basePath = "/docs";
const assetPrefix = process.env.NEXT_PUBLIC_ASSET_PREFIX || basePath;
const extraConfig = {};
if (isStatic) {
extraConfig.output = "export";
extraConfig.trailingSlash = true;
extraConfig.skipTrailingSlashRedirect = true;
}
module.exports = {
...extraConfig,
basePath,
env: { NEXT_PUBLIC_BASE_PATH: basePath },
assetPrefix,
experimental: { globalNotFound: true },
images: {
...(assetPrefix ? { path: `${assetPrefix}/_next/image` } : {}),
remotePatterns: [
{
protocol: "https",
hostname: "assets.tina.io",
port: "",
},
],
},
outputFileTracingIncludes: {
"/api/**/*": [],
},
outputFileTracingExcludes: {
"/api/**/*": [
".next/cache/**/*",
"node_modules/@swc/core-linux-x64-gnu",
"node_modules/@swc/core-linux-x64-musl",
"node_modules/@esbuild/",
"node_modules/webpack",
"node_modules/terser",
".git/**/*",
"public/**/*",
],
},
async rewrites() {
return [
{
source: "/admin",
destination: "/admin/index.html",
},
];
},
async redirects() {
const hostRootRedirects = [
{
source: "/",
destination: `${basePath}`,
permanent: false,
basePath: false,
},
{
source: "/admin",
destination: `${basePath}/admin`,
permanent: false,
basePath: false,
},
{
source: "/admin/:path*",
destination: `${basePath}/admin/:path*`,
permanent: false,
basePath: false,
},
];
return [
...hostRootRedirects,
...redirects.map((redirect) => ({
source: redirect.source,
destination: redirect.destination,
permanent: redirect.permanent,
...(redirect.basePath === false ? { basePath: false } : {}),
})),
];
},
turbopack: {
resolveExtensions: [".mdx", ".tsx", ".ts", ".jsx", ".js", ".mjs", ".json"],
// Add this rule to handle SVG as React components for Local Development
rules: {
"*.svg": {
loaders: ["@svgr/webpack"],
as: "*.js",
},
},
},
webpack: (config, { isServer }) => {
if (!isServer) {
// Configure Monaco Editor for minimal build
config.plugins.push(
new MonacoWebpackPlugin({
languages: ["javascript"],
filename: "static/[name].worker.js",
features: ["!gotoSymbol"], // Disable heavy features
})
);
}
// Add this module rule to handle SVG as React components for Production
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
// Optimize bundle size for serverless functions
if (isServer) {
config.externals = [...(config.externals || []), "fs", "path", "os"];
}
return config;
},
};