# Config file

The config file enables you to customize the scanning process. You can define `include` and `ignore` properties to designate which directories to scan and utilize `exports` and `aliases` properties to let the CLI resolve the correct entry points and recognize the aliases to ensure data accuracy.

## Locating the config file

The configuration file for the CLI can be placed in the following locations:

* An `omlet` property in the `package.json` file.
* An `.omletrc` file in JSON or YAML format in the root directory of your repository
* An `.omletrc.json`, `.omletrc.yaml`, `.omletrc.yml`, or `.omletrc.js` file in the root directory of your repository

Alternatively, you can also specify a custom configuration file name and location using the `--config` option in the CLI command:

{% tabs %}
{% tab title="npm" %}

```sh
npx @omlet/cli analyze --config './path/file'
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn dlx @omlet/cli analyze --config './path/file'
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm dlx @omlet/cli analyze --config './path/file'
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Auto-completion and error highlighting are available for the CLI configuration in popular IDEs like JetBrains and VS Code. Make sure to add Omlet's [schema](https://json.schemastore.org/omletrc.json) to your config file and have the CLI version 1.7.0 or above.

<pre class="language-json" data-title=".omletrc"><code class="lang-json">{
<strong>    "$schema": "https://json.schemastore.org/omletrc.json",
</strong>    "exports": {
        ...
    }
}
</code></pre>

{% endhint %}

## Properties

The configuration file can include the following properties:

<details>

<summary>include</summary>

Specifies an array of filenames or glob patterns to include in the scan.

{% code title=".omletrc" %}

```json
{
  "include": string[]
}
```

{% endcode %}

The paths and patterns are resolved relative to the root project path, where the **`-r`** parameter points to—or to the current working directory if **`-r`** is not provided.

{% code title=".omletrc" %}

```json
{
  "include": [
    "glob/one", 
    "glob/two"
  ]
}
```

{% endcode %}

You can learn more about the `include` property [here](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/excluding-certain-components-and-files).

</details>

<details>

<summary>ignore</summary>

Specifies an array of filenames or glob patterns that should be excluded from the scan.

{% code title=".omletrc" %}

```json
{
    "ignore": string[]
}
```

{% endcode %}

Similar to the **`include`** property, these are resolved relative to the root project path.

{% code title=".omletrc" lineNumbers="true" %}

```json
{
  "ignore": [
    "**/test_folder/**", 
    "**/another_test_folder/**"
  ]
}
```

{% endcode %}

You can learn more about the `ignore` property [here](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/excluding-certain-components-and-files).

</details>

<details>

<summary>tsconfigpath</summary>

A string that specifies the path to your tsconfig file.

{% code title=".omletrc" lineNumbers="true" %}

```json
{
  "tsconfigPath": "tsconfig.frontend.json"
}
```

{% endcode %}

</details>

<details>

<summary>exports</summary>

The **`exports`** property is a series of entries that tells the CLI about the corresponding entry points of a package in the source code. This is required to resolve imports from external dependencies.

{% code title=".omletrc" %}

```json
"exports": {
    [name: string]: string[]
}
```

{% endcode %}

The Omlet CLI follows the same format and convention as Node.js for the exports configuration—except for the conditional exports. The main entry point,<mark style="color:blue;">**`import { … } "@acme/design-system"`**</mark>, is designated with "."

The **`exports`** property should be an object consisting of key-value pairs. The key represents the package export, while the value should be a string that specifies the location of the corresponding source module.

{% code title=".omletrc" lineNumbers="true" %}

```json
{
  "exports": {
    ".": "src/index.ts"
  }
}
```

{% endcode %}

You can learn more about the `exports` property [here](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/resolve-imports-from-external-dependencies).

</details>

<details>

<summary>aliases</summary>

The **`aliases`** field allows you to define custom alias configurations that are used by bundlers such as Webpack, Vite, or Babel. If you have a custom alias configuration for your bundler, it's also important to configure it for Omlet.

{% code title=".omletrc" %}

```json
{
    "aliases": {
        [name: string]: string[]
    }
}
```

{% endcode %}

The **`aliases`** property should be an object consisting of key-value pairs. The key represents the alias string used in the codebase, while the value should be an array of strings that specify the location(s) of the corresponding file or files.

{% code title=".omletrc" lineNumbers="true" %}

```json
{
  "aliases": {
    "@utils": ["./src/utils/index.ts"],
    "@components/*": [
      "./src/components/*/index.ts",
      "./src/legacy-components/*/index.ts"
    ]
  }
}
```

{% endcode %}

This structure is adopted from the **`paths`** property in **`tsconfig`**. For more in-depth information, please refer to the [tsconfig documentation on paths](https://www.typescriptlang.org/tsconfig#paths).

You can learn more about the `aliases` property [here](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/map-aliases).

</details>

<details>

<summary>workspaces</summary>

An object to define package-specific configurations for `exports` and `aliases`.

{% code title=".omletrc" %}

```json
"workspaces": {
  [packageName: string]: {
    "aliases": {
      [name: string]: string[]
    }
  }
}
```

{% endcode %}

If your project is a monorepo with multiple packages, then you can use the `"workspaces"` field for package-specific configuration.

{% code title=".omletrc" lineNumbers="true" %}

```json
{
  "workspaces": {
    "@acme/design-system": {
      "exports": {
        ".": "./src/index.ts"
      },
      "aliases": {}
    },
    "@acme/components": {
      "aliases": {
        "@utils": ["./src/utils/index.ts"]
      }
    }
  }
}
```

{% endcode %}

Paths and patterns used in package-specific configurations are resolved relative to the root of corresponding packages.

For example, if `@acme/components` is located under `packages/components`, then the pattern used for the `@utils` alias is resolved to `packages/component/src/utils/index.ts`.

</details>

{% hint style="info" %} <mark style="color:blue;">**`include`**</mark>, <mark style="color:blue;">**`ignore`**</mark>, and <mark style="color:blue;">**`tsconfigPath`**</mark> properties can be set using either command-line arguments or the configuration file. If a property is provided as a command-line argument, the corresponding value in the configuration file will be ignored. A default value will be used if a property is not set via the configuration file or command-line argument.
{% endhint %}

## Next steps

Below are the docs explaining the most common use cases for the config file.

* [Exports configuration](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/resolve-imports-from-external-dependencies)
* [Mapping aliases](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/map-aliases)
* [Excluding certain components & files](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/excluding-certain-components-and-files)
* [Tutorial: Config file](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/config-file/tutorial-config-file)

{% hint style="info" %}
**Issues with your component data?**

If you think your component data in Omlet is inaccurate or if you see data issues on the Web app, you might need to set `exports` and/or `aliases`. Learn more [here](https://docs.omlet.dev/cli-and-dashboard/learn-omlet-cli/ensure-data-accuracy).
{% endhint %}
