next.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { NextConfig } from "next";
  2. import createNextIntlPlugin from "next-intl/plugin";
  3. // Create next-intl plugin with i18n request configuration
  4. const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
  5. const nextConfig: NextConfig = {
  6. output: "standalone",
  7. // 转译 ESM 模块(@lobehub/icons 需要)
  8. transpilePackages: ["@lobehub/icons"],
  9. // 排除服务端专用包(避免打包到客户端)
  10. // bull 和相关依赖只在服务端使用,包含 Node.js 原生模块
  11. // postgres 和 drizzle-orm 包含 Node.js 原生模块(net, tls, crypto, stream, perf_hooks)
  12. serverExternalPackages: [
  13. "bull",
  14. "bullmq",
  15. "@bull-board/api",
  16. "@bull-board/express",
  17. "ioredis",
  18. "postgres",
  19. "drizzle-orm",
  20. "pino",
  21. "pino-pretty",
  22. "thread-stream",
  23. ],
  24. // 强制包含 undici 到 standalone 输出
  25. // Next.js 依赖追踪无法正确追踪动态导入和类型导入的传递依赖
  26. // 参考: https://nextjs.org/docs/app/api-reference/config/next-config-js/output
  27. outputFileTracingIncludes: {
  28. "/**": ["./node_modules/undici/**/*", "./node_modules/socks-proxy-agent/**/*"],
  29. },
  30. // 文件上传大小限制(用于数据库备份导入)
  31. // Next.js 15 通过 serverActions.bodySizeLimit 统一控制
  32. experimental: {
  33. serverActions: {
  34. bodySizeLimit: "500mb",
  35. },
  36. },
  37. };
  38. // Wrap the Next.js config with next-intl plugin
  39. export default withNextIntl(nextConfig);