/** * Search-box.ai * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * File: apps/web/next.config.mjs * Description: Next.js config — loads repo-root .env and transpiles workspace packages. */ import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; // Secrets live in the repo-root .env (gitignored); Next only auto-loads app-dir env files. const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); try { for (const line of readFileSync(join(repoRoot, ".env"), "utf8").split("\n")) { const m = line.match(/^([A-Z0-9_]+)=(.*)$/); if (m && process.env[m[1]] === undefined) process.env[m[1]] = m[2]; } } catch { // .env optional when vars are exported by the environment } /** @type {import('next').NextConfig} */ const nextConfig = { transpilePackages: [ "@search-box/agent", "@search-box/anthropic", "@search-box/db", "@search-box/events", "@search-box/firecrawl", "@search-box/research", "@search-box/shared" ], serverExternalPackages: ["pg"], webpack: (config) => { // Workspace packages use ESM ".js" import specifiers for ".ts" sources. config.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"] }; return config; } }; export default nextConfig;