Copybook
Reference

Config

copybook.config.ts

copybook.config.ts
import { defineConfig } from "@copybook/cli";

export default defineConfig({
  content: ["src/**/*.prompts.ts"],
  exclude: ["src/legacy/**"],
  tsconfig: "tsconfig.json",
  stubs: ["server-only"],
  verify: ["verify/**/*.verify.ts"],
  usage: { include: ["src/**/*.tsx"] },
  snapshots: { dir: "copybook/snapshots" },
  placements: {
    "console/create-project": { route: "/projects/new" },
  },
});
OptionDescription
contentGlobs of files that export definitions, relative to the config file. Required.
verifyGlobs of files that export defineTest, defineFixture, and defineEval specs. Your product never imports these.
excludeGlobs to leave out. node_modules, dist, and .next are always excluded.
tsconfigUsed to resolve path aliases such as @/. Defaults to tsconfig.json.
stubsModules to replace with empty ones while loading content, such as server-only. CSS imports are always stubbed.
snapshots.dirWhere snapshots are written. Defaults to copybook/snapshots.
usage.include, usage.excludeProduct files to scan for imports of definitions, for usages, check, report, and Studio.
placementsKnown placements, each with an optional route and description. When you set this, check fails on placements that aren't listed.

How content loads

The CLI bundles your content files with esbuild, so tsconfig path aliases and extensionless imports work, then imports the bundle. npm dependencies stay external and resolve from your node_modules.

Only exported definitions are found, including ones inside exported arrays, objects, and collections. A definition that's only embedded in another one still appears in that definition's snapshot, but it doesn't get a snapshot of its own.

Keep content files free of imports that only work inside your app, such as React components or database clients, or list those modules in stubs.

On this page