PandaWiki/web/app/next.config.ts

88 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

2025-09-03 17:14:30 +08:00
import { withSentryConfig } from '@sentry/nextjs';
2025-07-16 21:45:06 +08:00
import type { NextConfig } from 'next';
2025-05-22 22:21:05 +08:00
const nextConfig: NextConfig = {
2025-06-09 19:53:51 +08:00
distDir: 'dist',
2025-05-22 22:21:05 +08:00
reactStrictMode: false,
allowedDevOrigins: ['10.10.18.71'],
2025-05-22 22:21:05 +08:00
output: 'standalone',
logging: {
fetches: {
fullUrl: true,
},
},
2025-10-11 19:13:35 +08:00
transpilePackages: ['mermaid'],
async headers() {
return [
{
source: '/cap@0.0.6/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, must-revalidate',
},
],
},
];
},
2025-05-22 22:21:05 +08:00
async rewrites() {
const rewritesPath = [];
if (process.env.NODE_ENV === 'development') {
rewritesPath.push(
...[
{
source: '/static-file/:path*',
destination: `${process.env.STATIC_FILE_TARGET}/static-file/:path*`,
2025-05-22 22:21:05 +08:00
basePath: false as const,
2025-07-16 21:45:06 +08:00
},
{
source: '/share/v1/:path*',
destination: `${process.env.TARGET}/share/v1/:path*`,
2025-07-16 21:45:06 +08:00
basePath: false as const,
},
],
2025-05-22 22:21:05 +08:00
);
}
return rewritesPath;
},
};
2025-09-24 19:19:41 +08:00
// 在开发环境下跳过 Sentry 配置
const isDevelopment = process.env.NODE_ENV === 'development';
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
export default isDevelopment
? nextConfig
: withSentryConfig(nextConfig, {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
org: 'sentry',
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
project: 'pandawiki-app',
sentryUrl: 'https://sentry.baizhi.cloud/',
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: '/monitoring',
2025-09-03 17:14:30 +08:00
2025-09-24 19:19:41 +08:00
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
});