Skip to main content

Config file

The CLI reads its configuration from mdcms.config.ts at the project root. Use defineConfig and defineType from @mdcms/cli to get full type safety.
mdcms.config.ts

Config options

All properties accepted by defineConfig:

Locale options

Type definition options

Each defineType(name, options) accepts:

Environment files

The CLI loads .env* files before importing mdcms.config.ts, so config files can read values from process.env:
mdcms.config.ts
Env files are read from the directory that contains the resolved mdcms.config.ts, mdcms.config.js, or mdcms.config.mjs. If you pass --config ./config/mdcms.config.ts, the CLI looks for env files in ./config. Without --config, the CLI searches upward from the current directory for the nearest config file. Put local developer values in .env.local next to mdcms.config.ts:
.env.local
Loading order, highest precedence first:
NODE_ENV is only the dotenv file selector. It controls names such as .env.production; it does not select the MDCMS content environment. Use MDCMS_ENVIRONMENT or the config environment field to choose an MDCMS environment such as staging or production.
NODE_ENV defaults to development when unset. Shell-exported variables override all file values, so CI secrets and one-off command exports always win. Use --no-env-file or MDCMS_DOTENV=0 to disable automatic env file loading for a run.

Manifest file

The manifest tracks the mapping between server documents and local files. It is stored at .mdcms.manifest.json in the project root, scoped to the current project and environment.
The manifest file should be added to .gitignore. It contains local state that varies between developers and environments.

Structure

The manifest is a JSON object where each key is a documentId and the value describes the local file:
.mdcms.manifest.json

Schema state

After each mdcms schema sync, the CLI writes a state file to:
For example, marketing-site project in the development environment produces:

Contents

.mdcms/schema/marketing-site.development.json
The schemaHash is required by mdcms push to validate that content is being pushed against the correct schema version. If this file is missing or the hash is stale, push operations will fail.
The .mdcms/ directory should be added to .gitignore. The mdcms init wizard does this automatically.

File mapping

The CLI maps server documents to local files based on the type’s directory setting and the document’s path and locale.

Localized documents

Localized types produce files with the locale code inserted before the file extension:
For example, a BlogPost document with path hello-world, locale en, and format mdx:
The same document in French:

Non-localized documents

Non-localized types use a simpler pattern without the locale segment:
For example, an Author document with path jane-doe and format md: