2025-10-20 16:26:47 +09:00
|
|
|
import path from "node:path";
|
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
|
|
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
2025-12-10 13:59:41 +09:00
|
|
|
const workspaceRoot = path.resolve(__dirname, "..", "..");
|
|
|
|
|
|
2025-12-25 17:51:02 +09:00
|
|
|
// BFF URL for development API proxying
|
|
|
|
|
const BFF_URL = process.env.BFF_URL || "http://localhost:4000";
|
|
|
|
|
const isDev = process.env.NODE_ENV === "development";
|
|
|
|
|
|
2025-08-20 18:02:50 +09:00
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
|
const nextConfig = {
|
2025-08-30 16:45:22 +09:00
|
|
|
output: process.env.NODE_ENV === "production" ? "standalone" : undefined,
|
2025-08-22 17:02:49 +09:00
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
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;
|
|
|
|
|
},
|
2025-08-20 18:02:50 +09:00
|
|
|
|
|
|
|
|
env: {
|
2025-12-25 17:51:02 +09:00
|
|
|
// 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,
|
2025-08-20 18:02:50 +09:00
|
|
|
NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME,
|
|
|
|
|
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION,
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-25 17:51:02 +09:00
|
|
|
// Proxy API requests to BFF in development
|
|
|
|
|
async rewrites() {
|
|
|
|
|
if (!isDev) return [];
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
source: "/api/:path*",
|
|
|
|
|
destination: `${BFF_URL}/api/:path*`,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
|
2025-08-20 18:02:50 +09:00
|
|
|
compiler: {
|
2025-08-22 17:02:49 +09:00
|
|
|
removeConsole: process.env.NODE_ENV === "production",
|
2025-08-20 18:02:50 +09:00
|
|
|
},
|
|
|
|
|
|
2025-09-26 15:51:07 +09:00
|
|
|
experimental: {
|
2025-12-10 13:59:41 +09:00
|
|
|
optimizePackageImports: ["@heroicons/react", "@tanstack/react-query"],
|
2025-09-26 15:51:07 +09:00
|
|
|
},
|
|
|
|
|
|
2025-09-01 15:11:42 +09:00
|
|
|
typescript: { ignoreBuildErrors: false },
|
2025-08-20 18:02:50 +09:00
|
|
|
};
|
|
|
|
|
|
2025-12-11 18:47:24 +09:00
|
|
|
// 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;
|