Assist_Design/apps/portal/next.config.mjs
tema f775a62c64 Update pnpm-lock.yaml and Refactor BFF Order Management
- Updated pnpm-lock.yaml to standardize quotes and improve consistency across dependencies.
- Added @nestjs/swagger and swagger-ui-express to the BFF package.json for enhanced API documentation.
- Refactored notifications service to utilize Prisma types for better type safety.
- Removed orders controller, DTO, and orchestrator service to streamline order management functionality.
- Enhanced next.config.mjs to support API proxying in development, improving local development experience.
2025-12-25 17:51:02 +09:00

68 lines
1.9 KiB
JavaScript

import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const workspaceRoot = path.resolve(__dirname, "..", "..");
// BFF URL for development API proxying
const BFF_URL = process.env.BFF_URL || "http://localhost:4000";
const isDev = process.env.NODE_ENV === "development";
/** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.NODE_ENV === "production" ? "standalone" : undefined,
turbopack: {
resolveAlias: {
"@customer-portal/domain": path.join(workspaceRoot, "packages/domain/dist"),
},
},
webpack(config) {
config.resolve.alias = {
...config.resolve.alias,
"@customer-portal/domain": path.join(workspaceRoot, "packages/domain/dist"),
};
return config;
},
env: {
// In development, we use rewrites to proxy API calls, so API_BASE is same-origin
// In production, API_BASE should be set via environment (nginx proxy or direct BFF URL)
NEXT_PUBLIC_API_BASE: isDev ? "" : process.env.NEXT_PUBLIC_API_BASE,
NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME,
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION,
},
// Proxy API requests to BFF in development
async rewrites() {
if (!isDev) return [];
return [
{
source: "/api/:path*",
destination: `${BFF_URL}/api/:path*`,
},
];
},
compiler: {
removeConsole: process.env.NODE_ENV === "production",
},
experimental: {
optimizePackageImports: ["@heroicons/react", "@tanstack/react-query"],
},
typescript: { ignoreBuildErrors: false },
};
// Only load bundle analyzer when explicitly requested
let exportedConfig = nextConfig;
if (process.env.ANALYZE === "true") {
const bundleAnalyzer = (await import("@next/bundle-analyzer")).default;
exportedConfig = bundleAnalyzer({ enabled: true })(nextConfig);
}
export default exportedConfig;