/** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful * for Docker builds. */ // Copyright (c) 2025 Bytedance Ltd. and/or its affiliates // SPDX-License-Identifier: MIT import "./src/env.js"; import createNextIntlPlugin from 'next-intl/plugin'; const withNextIntl = createNextIntlPlugin('./src/i18n.ts'); /** @type {import("next").NextConfig} */ // DeepFlow leverages **Turbopack** during development for faster builds and a smoother developer experience. // However, in production, **Webpack** is used instead. // // This decision is based on the current recommendation to avoid using Turbopack for critical projects, as it // is still evolving and may not yet be fully stable for production environments. const config = { // For development mode turbopack: { rules: { "*.md": { loaders: ["raw-loader"], as: "*.js", }, }, }, // For production mode webpack: (config) => { config.module.rules.push({ test: /\.md$/, use: "raw-loader", }); return config; }, // ... rest of the configuration. output: "standalone", // Docker standalone 部署:把 /deepflow-backend/* 代理到 deepflow-backend 服务。 // 前端以 NEXT_PUBLIC_API_URL=/deepflow-backend 构建(见 // src/core/api/resolve-service-url.ts,直接拼 origin + /deepflow-backend/), // 而后端路由均带 /api 前缀(见 src/server/app.py)。由 Next 服务端补上 /api 前缀, // 避免浏览器跨端口 / CORS 问题。目标地址可用 DEEPFLOW_BACKEND_HOST 覆盖。 async rewrites() { const backendHost = process.env.DEEPFLOW_BACKEND_HOST || "http://deepflow-backend:8000"; return [ { source: "/deepflow-backend/:path*", destination: `${backendHost}/api/:path*` }, { source: "/deepflow-backend", destination: `${backendHost}/api/` }, ]; }, }; export default withNextIntl(config);