- Add Unsloth OpenAI-compatible provider with @ai-sdk/openai - Rewrite AI generation handlers with Vercel AI SDK streaming - Add plainTextToLexicalJson helper for richText field generation - Configure HeadingFeature and PayloadAiPluginLexicalEditorFeature - Stub @payloadcms/richtext-lexical server entry in client bundle - Extract meta constants for site title and description - Add UNSLOTH_API_KEY to .env.development
61 lines
2.3 KiB
JavaScript
61 lines
2.3 KiB
JavaScript
import { withPayload } from "@payloadcms/next/withPayload";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import packageJson from "./package.json" with { type: "json" };
|
|
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
// Your Next.js config here
|
|
env: {
|
|
version: packageJson.version,
|
|
},
|
|
// Pin the workspace root to this repo dir so the standalone build emits a
|
|
// flat .next/standalone/server.js (Next otherwise walks up looking for
|
|
// lockfiles and can pick a parent directory — here a stray
|
|
// /home/jason/package-lock.json two levels up would nest the standalone
|
|
// tree under .next/standalone/WebstormProjects/polaris-task-force/, which
|
|
// breaks the Dockerfile's `COPY .../standalone ./` + `CMD ["node","server.js"]`).
|
|
outputFileTracingRoot: path.resolve(path.dirname(fileURLToPath(import.meta.url))),
|
|
webpack: (webpackConfig, { isServer }) => {
|
|
webpackConfig.resolve.extensionAlias = {
|
|
".cjs": [".cts", ".cjs"],
|
|
".js": [".ts", ".tsx", ".js", ".jsx"],
|
|
".mjs": [".mts", ".mjs"],
|
|
};
|
|
|
|
// @ai-stack/payloadcms client components (Compose -> setSafeLexicalState ->
|
|
// lexicalToHTML) import the *server* entry of @payloadcms/richtext-lexical, which
|
|
// transitively pulls in `payload` and all Node built-ins (node:fs, node:crypto,
|
|
// child_process, worker_threads, ...). The client only needs two pure string
|
|
// constants (BLOCK_PLACEHOLDER_PREFIX/SUFFIX) from lexicalToHTML; the server-only
|
|
// convertLexicalToHTML is never invoked client-side. Stub the bare server entry in
|
|
// the client bundle so the transitive import chain breaks. The `$` makes it an
|
|
// exact-match alias, leaving the legitimate `@payloadcms/richtext-lexical/client`
|
|
// subpath and the server bundle unaffected.
|
|
if (!isServer) {
|
|
webpackConfig.resolve.alias = {
|
|
...webpackConfig.resolve.alias,
|
|
"@payloadcms/richtext-lexical$": false,
|
|
};
|
|
}
|
|
|
|
return webpackConfig;
|
|
},
|
|
transpilePackages: [
|
|
"@payloadcms/richtext-lexical",
|
|
"lexical",
|
|
"@lexical/react",
|
|
"@lexical/rich-text",
|
|
"@lexical/history",
|
|
"@lexical/list",
|
|
"@lexical/link",
|
|
"@lexical/markdown",
|
|
"@lexical/selection",
|
|
"@lexical/table",
|
|
"@lexical/utils",
|
|
],
|
|
output: "standalone",
|
|
};
|
|
|
|
export default withPayload(nextConfig, { devBundleServerPackages: true });
|