import { readFileSync } from 'node:fs'; import path from 'node:path'; import type { NextConfig } from 'next'; import createNextIntlPlugin from 'next-intl/plugin'; // Bauzeit-Einbettung der Aenderungsliste (quick-260916-dcz): CHANGELOG.md aus // dem Wurzelverzeichnis wird hier gelesen und als `env.TESSERA_CHANGELOG_MD` // abgelegt. Next.js ersetzt `process.env.TESSERA_CHANGELOG_MD` fuer webpack UND // Turbopack ueber denselben Define-Mechanismus. Der Text bleibt nur im // Server-Bundle, weil ausschliesslich Server-Code `@/lib/changelog` importiert: // die Server-Seite (changelog/page.tsx) und die 'use server'-Datei // lib/release-notice-actions.ts (quick-260925-bow) — Importdisziplin, kein // Client-Chunk. const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts'); function readChangelog(): string { const file = path.resolve(__dirname, '../../CHANGELOG.md'); try { return readFileSync(file, 'utf8'); } catch (error) { const reason = error instanceof Error ? error.message : String(error); throw new Error( `CHANGELOG.md konnte nicht gelesen werden (${file}): ${reason}. ` + 'Die Datei muss im Wurzelverzeichnis liegen; im Docker-Bau braucht sie die Ausnahme ' + '`!CHANGELOG.md` in .dockerignore und die Zeile `COPY CHANGELOG.md ./` in apps/web/Dockerfile.', ); } } const nextConfig: NextConfig = { output: 'standalone' as const, env: { TESSERA_CHANGELOG_MD: readChangelog(), }, async rewrites() { const apiUrl = process.env.API_INTERNAL_URL || 'http://api:3001'; return [ { source: '/api-proxy/:path*', destination: `${apiUrl}/:path*`, }, ]; }, }; export default withNextIntl(nextConfig);