-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
67 lines (57 loc) · 2.34 KB
/
next.config.ts
File metadata and controls
67 lines (57 loc) · 2.34 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
import nextMDX from "@next/mdx";
import { withSentryConfig } from "@sentry/nextjs";
import { type NextConfig } from "next";
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: string) => {
try {
const resolved = import.meta.resolve(packageName);
const resolvedPath = resolved.startsWith("file:") ? fileURLToPath(resolved) : resolved;
return !resolvedPath.includes(".pnpm");
} catch (error) {
// Fallback: If import.meta.resolve fails (e.g. older node), assume false
console.warn(` ⚠️ warn Could not resolve package ${packageName}: ${(error as Error).message}`);
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: NextConfig = {
outputFileTracingRoot: __dirname,
output: process.env.OUTPUT_TYPE as NextConfig["output"],
generateBuildId: process.env.GIT_SHA ? () => process.env.GIT_SHA ?? null : undefined,
typescript: { ignoreBuildErrors: true },
eslint: { ignoreDuringBuilds: 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,
// Enable production source maps for Sentry error reporting
productionBrowserSourceMaps: true,
};
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 },
// Hides source maps from generated client bundles
hideSourceMaps: true,
});
export default nextConfig;