next.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. ],
  21. // 强制包含 undici 和 fetch-socks 到 standalone 输出
  22. // Next.js 依赖追踪无法正确追踪动态导入和类型导入的传递依赖
  23. // 参考: https://nextjs.org/docs/app/api-reference/config/next-config-js/output
  24. outputFileTracingIncludes: {
  25. "/**": [
  26. "./node_modules/undici/**/*",
  27. "./node_modules/fetch-socks/**/*",
  28. "./node_modules/ws/**/*",
  29. ],
  30. },
  31. // 文件上传大小限制(用于数据库备份导入)
  32. // Next.js 15 通过 serverActions.bodySizeLimit 统一控制
  33. experimental: {
  34. serverActions: {
  35. bodySizeLimit: "500mb",
  36. },
  37. proxyClientMaxBodySize: "100mb",
  38. },
  39. };
  40. // Wrap the Next.js config with next-intl plugin
  41. export default withNextIntl(nextConfig);