next.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. "/**": ["./node_modules/undici/**/*", "./node_modules/fetch-socks/**/*"],
  26. },
  27. // 文件上传大小限制(用于数据库备份导入)
  28. // Next.js 15 通过 serverActions.bodySizeLimit 统一控制
  29. experimental: {
  30. serverActions: {
  31. bodySizeLimit: "500mb",
  32. },
  33. proxyClientMaxBodySize: "100mb",
  34. },
  35. };
  36. // Wrap the Next.js config with next-intl plugin
  37. export default withNextIntl(nextConfig);