import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // standalone 仅用于生产构建；dev 模式启用会导致 routes-manifest 缺失（Windows 下 ENOENT）
  ...(process.env.NODE_ENV === "production" ? { output: "standalone" as const } : {}),
  // RPA 链（playwright-extra → puppeteer-extra-plugin → merge-deep → clone-deep）含动态 require，禁止 webpack 打包
  serverExternalPackages: [
    "playwright",
    "playwright-core",
    "playwright-extra",
    "puppeteer-extra-plugin",
    "puppeteer-extra-plugin-stealth",
    "puppeteer-extra-plugin-user-data-dir",
    "puppeteer-extra-plugin-user-preferences",
    "clone-deep",
    "merge-deep",
    "lazy-cache",
    "ioredis",
  ],
};

export default nextConfig;
