-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.mjs
More file actions
60 lines (50 loc) · 2.05 KB
/
Copy pathnext.config.mjs
File metadata and controls
60 lines (50 loc) · 2.05 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
import nextMDX from "@next/mdx";
import { withSentryConfig } from "@sentry/nextjs";
import nextRoutes from "nextjs-routes/config";
import { fileURLToPath } from "node:url";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const withRoutes = nextRoutes({ outDir: "types" });
const withMDX = nextMDX({
extension: /\.mdx?$/u,
options: { providerImportSource: "@mdx-js/react", jsxImportSource: "@emotion/react" },
});
const isPackageLocal = (packageName) => {
try {
const resolved = import.meta.resolve(packageName);
const resolvedPath = resolved.startsWith("file:") ? fileURLToPath(resolved) : resolved;
return !resolvedPath.includes(".pnpm");
} catch (error) {
console.warn(
`warn Could not resolve package ${packageName}: ${error instanceof Error ? error.message : String(error)}`,
);
return false;
}
};
const transpilePackages = ["@squonk/mui-theme", "@squonk/sdf-parser"].filter((pkg) =>
isPackageLocal(pkg),
);
console.log("Transpiling packages:", transpilePackages);
/** @type {import("next").NextConfig} */
let nextConfig = {
outputFileTracingRoot: __dirname,
output: /** @type {import("next").NextConfig["output"]} */ (process.env.OUTPUT_TYPE),
generateBuildId: process.env.GIT_SHA ? () => process.env.GIT_SHA ?? null : undefined,
typescript: { ignoreBuildErrors: true },
// reactStrictMode: true, // TODO: Blocked by @rjsf Form using UNSAFE_componentWillReceiveProps
pageExtensions: ["js", "ts", "jsx", "tsx", "mdx"],
// replace empty string with undefined
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
basePath: process.env.NEXT_PUBLIC_BASE_PATH || undefined,
transpilePackages,
};
nextConfig = withMDX(nextConfig);
nextConfig = withRoutes(nextConfig);
nextConfig = withSentryConfig(nextConfig, {
// Suppresses source map uploading logs during build
silent: true,
org: "informatics-matters",
project: "data-manager-ui",
// Automatically delete source maps after uploading them to Sentry
sourcemaps: { deleteSourcemapsAfterUpload: true },
});
export default nextConfig;