Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m11s
Monorepo Pipeline / 🏗️ Build (push) Successful in 3m2s
Monorepo Pipeline / 🧹 Lint (push) Successful in 3m15s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
🏥 Server Maintenance / 🧹 Prune & Clean (push) Failing after 17s
100 lines
2.4 KiB
JavaScript
100 lines
2.4 KiB
JavaScript
/* global process, URL */
|
|
import createNextIntlPlugin from "next-intl/plugin";
|
|
import { withSentryConfig } from "@sentry/nextjs";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
export const baseNextConfig = {
|
|
output: "standalone",
|
|
turbopack: {},
|
|
images: {
|
|
dangerouslyAllowSVG: true,
|
|
contentDispositionType: "attachment",
|
|
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
|
|
},
|
|
async rewrites() {
|
|
const umamiUrl = (
|
|
process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL ||
|
|
"https://analytics.infra.mintel.me"
|
|
).replace("/script.js", "");
|
|
const glitchtipUrl = process.env.SENTRY_DSN
|
|
? new URL(process.env.SENTRY_DSN).origin
|
|
: "https://errors.infra.mintel.me";
|
|
|
|
return [
|
|
{
|
|
source: "/stats/:path*",
|
|
destination: `${umamiUrl}/:path*`,
|
|
},
|
|
{
|
|
source: "/errors/:path*",
|
|
destination: `${glitchtipUrl}/:path*`,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
const withMintelConfig = (config) => {
|
|
const i18nPaths = [
|
|
"src/i18n/request.ts",
|
|
"src/i18n/request.tsx",
|
|
"i18n/request.ts",
|
|
"i18n/request.tsx",
|
|
"src/i18n.ts",
|
|
"src/i18n.tsx",
|
|
"i18n.ts",
|
|
"i18n.tsx",
|
|
];
|
|
|
|
const hasI18nConfig = i18nPaths.some((p) =>
|
|
fs.existsSync(path.resolve(process.cwd(), p)),
|
|
);
|
|
|
|
let nextConfig = { ...baseNextConfig, ...config };
|
|
|
|
// Explicitly merge rewrites
|
|
nextConfig.rewrites = async () => {
|
|
const defaultRewrites = await baseNextConfig.rewrites();
|
|
let customRewrites = {};
|
|
if (typeof config.rewrites === 'function') {
|
|
customRewrites = await config.rewrites();
|
|
} else if (Array.isArray(config.rewrites)) {
|
|
customRewrites = config.rewrites;
|
|
}
|
|
|
|
if (Array.isArray(customRewrites)) {
|
|
return {
|
|
beforeFiles: [...customRewrites, ...defaultRewrites],
|
|
afterFiles: [],
|
|
fallback: [],
|
|
};
|
|
}
|
|
|
|
return {
|
|
beforeFiles: [...(customRewrites.beforeFiles || []), ...defaultRewrites],
|
|
afterFiles: customRewrites.afterFiles || [],
|
|
fallback: customRewrites.fallback || [],
|
|
};
|
|
};
|
|
|
|
if (hasI18nConfig) {
|
|
const withNextIntl = createNextIntlPlugin();
|
|
nextConfig = withNextIntl(nextConfig);
|
|
}
|
|
|
|
return withSentryConfig(
|
|
nextConfig,
|
|
{
|
|
silent: !process.env.CI,
|
|
treeshake: { removeDebugLogging: true },
|
|
},
|
|
{
|
|
authToken: undefined,
|
|
},
|
|
);
|
|
};
|
|
|
|
export default withMintelConfig;
|
|
|