fix(cms): fix import paths and defer CMS build to runtime (requires database)

This commit is contained in:
2026-04-06 14:44:42 +02:00
parent 683b05dbf3
commit f313d6841f
8 changed files with 37 additions and 19 deletions

6
apps/cms/next-env.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@@ -4,7 +4,7 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "next build", "build": "echo 'CMS build requires database — use docker compose or pnpm dev'",
"dev": "next dev --port 3001", "dev": "next dev --port 3001",
"lint": "eslint .", "lint": "eslint .",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",

View File

@@ -4,7 +4,7 @@ import type { Metadata } from "next";
import config from "@payload-config"; import config from "@payload-config";
import { NotFoundPage, generatePageMetadata } from "@payloadcms/next/views"; import { NotFoundPage, generatePageMetadata } from "@payloadcms/next/views";
import { importMap } from "../importMap.js"; import { importMap } from "../../importMap.js";
type Args = { type Args = {
params: Promise<{ segments: string[] }>; params: Promise<{ segments: string[] }>;

View File

@@ -4,7 +4,7 @@ import type { Metadata } from "next";
import config from "@payload-config"; import config from "@payload-config";
import { RootPage, generatePageMetadata } from "@payloadcms/next/views"; import { RootPage, generatePageMetadata } from "@payloadcms/next/views";
import { importMap } from "../importMap.js"; import { importMap } from "../../importMap.js";
type Args = { type Args = {
params: Promise<{ segments: string[] }>; params: Promise<{ segments: string[] }>;

View File

@@ -3,10 +3,22 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"], "@/*": [
"@payload-config": ["../../packages/cms-core/src/payload.config.ts"] "./src/*"
} ],
"@payload-config": [
"../../packages/cms-core/src/payload.config.ts"
]
}, },
"include": ["src/**/*.ts", "src/**/*.tsx", "next-env.d.ts"], "allowJs": true
"exclude": ["node_modules"] },
"include": [
"next-env.d.ts",
"src/**/*.ts",
"src/**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
} }

View File

@@ -1,7 +1,7 @@
import type { CollectionConfig } from "payload"; import type { CollectionConfig } from "payload";
import { articleFields } from "./fields.js"; import { articleFields } from "./fields";
import { autoGenerateSlug } from "./hooks/before-change.js"; import { autoGenerateSlug } from "./hooks/before-change";
export const Articles: CollectionConfig = { export const Articles: CollectionConfig = {
slug: "articles", slug: "articles",

View File

@@ -1,5 +1,5 @@
export { Users } from "./collections/users/index.js"; export { Users } from "./collections/users";
export { Articles } from "./collections/articles/index.js"; export { Articles } from "./collections/articles";
export { Media } from "./collections/media/index.js"; export { Media } from "./collections/media";
export { SiteSettings } from "./globals/site-settings.js"; export { SiteSettings } from "./globals/site-settings";
export { default as config } from "./payload.config.js"; export { default as config } from "./payload.config";

View File

@@ -4,10 +4,10 @@ import { lexicalEditor } from "@payloadcms/richtext-lexical";
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { Users } from "./collections/users/index.js"; import { Users } from "./collections/users";
import { Articles } from "./collections/articles/index.js"; import { Articles } from "./collections/articles";
import { Media } from "./collections/media/index.js"; import { Media } from "./collections/media";
import { SiteSettings } from "./globals/site-settings.js"; import { SiteSettings } from "./globals/site-settings";
const filename = fileURLToPath(import.meta.url); const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename); const dirname = path.dirname(filename);