fix(web): skip payload withPayload in production build
Payload CMS v3.81 withPayload() injects a turbopack config key that Next.js 16.0.10 rejects in production builds (needs >=16.1). Load withPayload only in dev; production gets a pass-through. Payload admin works locally; production serves blog/changelog as regular Next.js pages querying the Payload API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
import { withPayload } from "@payloadcms/next/withPayload";
|
|
||||||
|
|
||||||
import env from "./env.config";
|
import env from "./env.config";
|
||||||
|
|
||||||
|
// Payload CMS requires Next.js >=16.1.0 for production builds (turbopack).
|
||||||
|
// Until we upgrade from 16.0.10, load withPayload only in dev where
|
||||||
|
// turbopack isn't used for builds. Production serves blog/changelog
|
||||||
|
// as static pages — Payload admin is dev-only for now.
|
||||||
|
const withPayload =
|
||||||
|
process.env.NODE_ENV === "production"
|
||||||
|
? (c: NextConfig) => c
|
||||||
|
: // eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
require("@payloadcms/next/withPayload").withPayload;
|
||||||
|
|
||||||
const INTERNAL_PACKAGES = [
|
const INTERNAL_PACKAGES = [
|
||||||
"@turbostarter/analytics-web",
|
"@turbostarter/analytics-web",
|
||||||
"@turbostarter/api",
|
"@turbostarter/api",
|
||||||
@@ -116,4 +125,4 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
|||||||
enabled: env.ANALYZE,
|
enabled: env.ANALYZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withPayload(withBundleAnalyzer(config));
|
export default withPayload(withBundleAnalyzer(config)) as NextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user