Configure a scan
Set up scout.config.json so the scan reads the right files in your repo.
This guide assumes the CLI and the rest of the repo's dependencies are installed. If they aren't, see Install the CLI. For a first run from start to finish, follow Scan your first repo.
Create the config with init
From the repo root, run:
npx scout init -y
init writes scout.config.json in the current folder. It has no include, so the scan reads the whole repository, and its exclude is empty.
-y skips the questions. Without it, in a terminal, init asks for your dashboard's address, the repository's name on the dashboard and the branch the dashboard tracks. In a monorepo, it also asks which packages or folders to leave out of the scan, and writes the ones you pick to exclude. With -y, pass --exclude <folder> for each folder to leave out.
If you run init in one package's folder of a monorepo, such as apps/web, and the repository root has no config yet, it asks whether to scan the whole repository instead. If you say yes, it writes the config at the repository root. With -y, it writes the config in the current folder and prints the command that writes it at the root instead, scout init --output ../../scout.config.json.
init sets repoId, the repo id the scan is recorded under, from the owner and name in your git remote, such as acme/storefront, or from the name of the config's folder if there is no remote. To use a different name, edit repoId in the file or pass --repo-id <name> to init.
init won't overwrite an existing config. Edit that file instead, or delete it and run init again. Every init flag is in the CLI reference.
Scan the whole repository
A config from init has no include, so it already scans every app and package below the config's folder. If your config has an include, delete it. Any exclude can stay as it is:
{
"$schema": "https://unpkg.com/@scoutui/cli/schema/config.schema.json",
"repoId": "storefront"
}
The scan then reads every JavaScript, TypeScript and Vue file there. To leave some of them out, use exclude, as below.
Scan only some folders
Add include and point it at the folders you want. Patterns are globs, relative to the folder that holds the config file.
For a repo that keeps its code in app/ and components/, list both folders:
{
"$schema": "https://unpkg.com/@scoutui/cli/schema/config.schema.json",
"repoId": "storefront",
"include": [
"app/**/*.{js,jsx,ts,tsx}",
"components/**/*.{js,jsx,ts,tsx}"
]
}
Leave out files you don't want counted
Add a pattern to exclude for anything you don't want counted, such as **/__mocks__/** for mocks or src/generated/** for generated code. To leave out a whole package of a monorepo, such as a playground app, name its folder:
{
"$schema": "https://unpkg.com/@scoutui/cli/schema/config.schema.json",
"repoId": "storefront",
"exclude": ["apps/playground"]
}
If nothing exists at a folder or file you name, for example after it was renamed, the scan warns and carries on:
Warning: "apps/playground" in exclude matches nothing. Update or remove it in ./scout.config.json.
Fix the path, or remove it from exclude.
The scan already leaves these out, so you don't need to exclude them:
- test, spec and story files, files in
__tests__folders, type declaration files (.d.ts,.d.mts,.d.cts) andnode_modules; - files your
.gitignoreignores; - folders whose names start with a dot, such as
.next; - a folder below the config's folder that holds its own git repository, such as a submodule, even when an
includepattern points into it.
Check that the scan reads your files
Scan without uploading:
npx scout scan --dry-run
The summary counts the files it read:
Scanned 3 files in 0.1s: 6 components, 5 uses.
The first number should be close to the number of source files you expect. If it's too low, narrow exclude, or widen include if your config has one. If it's too high, add to exclude. If there are no files to scan at all, the scan stops before reading anything. When include matches no files:
Error: No files match "include" in ./scout.config.json (app/**/*.{js,jsx,ts,tsx}, components/**/*.{js,jsx,ts,tsx}). Point it at your source files and scan again.
When the config has no include, and the config's folder holds no source files or exclude leaves them all out:
Error: No JavaScript, TypeScript or Vue files to scan in /home/dev/storefront. Check "exclude" in ./scout.config.json, or scan from the folder that holds your source files.
If the summary has lines like these, some of the repo's dependencies aren't installed:
Scout couldn't match 4 more uses to a component. See https://scoutui.dev/docs/guides/troubleshoot-a-scan#unresolved-occurrences
4 of them are from packages that aren't installed.
The components from those packages are missing from the scan. Run your package manager's install, then scan again.
If your imports use path aliases such as @/components, or the design system lives in another package of the same repo, see Resolve imports in a monorepo.
In a Nuxt app, run npx nuxt prepare (or dev or build) before you scan. Without the files it generates under .nuxt/, the scan warns that the app hasn't been prepared and can't find auto-imported components, and an upload refuses with:
Error: Couldn't upload the scan: this Nuxt app hasn't been prepared. Run npx nuxt prepare and try again.
Every config field, with its type and default, is in the config reference.