---
title: "documents.config.ts"
description: "Every option the template library's config file takes, and what each path is relative to. Experimental."
---

> Documentation Index
> Fetch the complete documentation index at: https://commentware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# documents.config.ts

`documents.config.ts` names a project's template directories, stylesheet,
Chrome and Vite plugins.

Every `commentware-documents` command run in the project reads it. The library
is experimental, so an option may change or be removed in any release, with no notice first.

The file is at the root of the project, beside `package.json`. It may also be
`documents.config.mts`, `.js` or `.mjs`, and a directory holding two of them is
refused. It is loaded with Vite, so it can be TypeScript and import the
project's own modules. Its default export is the result of `defineConfig`:

```ts title="documents.config.ts"
import { defineConfig } from "@commentware-private/documents";
import svgr from "vite-plugin-svgr";

export default defineConfig({
  templates: ["src/templates", "src/letters"],
  stylesheet: "src/templates/styles.css",
  browser: { executablePath: "/usr/bin/chromium" },
  vite: { plugins: [svgr()] },
});
```

A path is relative to the directory the file is in. An option the file does not
know is refused, with its name.

## `templates`

**Type:** a list of paths, at least one · **Default:** none, and required

The directories that hold templates. Every `.tsx` file under one, at any depth,
is a template, and its id is its path inside that directory without the
extension: `src/templates/quoting/compact-quote.tsx` is
`quoting/compact-quote`. Two directories that produce the same id are refused,
with both files named. A path that is not a directory is refused. Components a
template shares go outside these directories.

## `stylesheet`

**Type:** a path · **Default:** Tailwind alone

The CSS file a template's page loads, compiled with Tailwind. Every class a
template in `templates` uses is compiled, whatever the stylesheet's own
`@source` lines say. A stylesheet that writes `@import "tailwindcss"` needs
`tailwindcss` installed in the project. The file must exist.

## `outDir`

**Type:** a path · **Default:** `.documents`

Where `commentware-documents build` writes `templates.ts` and
`templates.entry.css`, and where `preview` keeps the entry it compiles. The
directory is generated, and belongs in `.gitignore`.

## `browser.executablePath`

**Type:** a path · **Default:** the Chrome for Testing that
`commentware-documents install-browser` downloads

The Chrome or Chromium a PDF is printed with. A path where nothing is installed
is refused when the first PDF is printed. A container that ships Chromium names
it here.

## `vite.plugins`

**Type:** a list of Vite plugins · **Default:** none

Plugins added after the library's own React and Tailwind plugins, for the
preview and for compiling the stylesheet. A template that imports a file Vite
cannot load on its own needs one here, such as `vite-plugin-svgr` for an
`import Logo from "./logo.svg?react"`. The project's `vite.config.ts` is not
read.