carpa_turborepo/apps/cms/next.config.mjs

41 lines
1.4 KiB
JavaScript

import { withPayload } from "@payloadcms/next/withPayload";
import path from "path";
import { fileURLToPath } from "url";
const dirname = path.dirname(fileURLToPath(import.meta.url));
const workspaceRoot = path.resolve(dirname, "../..");
/** @type {import('next').NextConfig} */
const nextConfig = {
// Compile the internal workspace packages from their TS source (JIT), so
// no separate build step is needed before running the CMS.
transpilePackages: ["@carpa/typesense", "@carpa/ui"],
// Allow the Portless HTTPS hostnames to load Next's dev assets (/_next/*).
// Without this, Next 16 blocks cross-origin dev requests and the admin
// renders as a blank, unhydrated page behind the proxy.
allowedDevOrigins: [
"cms.carpa.localhost",
"*.carpa.localhost",
"*.localhost",
],
images: {
localPatterns: [{ pathname: "/api/media/file/**" }],
},
webpack: (webpackConfig) => {
webpackConfig.resolve.extensionAlias = {
".cjs": [".cts", ".cjs"],
".js": [".ts", ".tsx", ".js", ".jsx"],
".mjs": [".mts", ".mjs"],
};
return webpackConfig;
},
// Monorepo: pin the workspace root so Turbopack/Next resolve `next` and
// compile linked workspace packages (e.g. @carpa/typesense) correctly.
turbopack: {
root: workspaceRoot,
},
outputFileTracingRoot: workspaceRoot,
};
export default withPayload(nextConfig, { devBundleServerPackages: false });