# CLI

PurgeCSS is available via a CLI. You can use the CLI by itself or with a configuration file.

## Installation

```
npm i -g purgecss
```

## Usage

To see the available options for the CLI: `purgecss --help`

```
purgecss --css <css> --content <content> [option]

Options:
  --con, --content  glob of content files                                [array]
  -c, --config      configuration file                                  [string]
  -o, --out         Filepath directory to write purified css files to   [string]
  -w, --whitelist   List of classes that should not be removed
                                                           [array] [default: []]
  -h, --help        Show help                                          [boolean]
  -v, --version     Show version number                                [boolean]
```

The options available through the CLI are similar to the ones available with a configuration file. You can also use the CLI with a configuration file.

### --css

```
purgecss --css css/app.css css/palette.css --content src/index.html
```

### --content

You can specify content that should be analyzed by PurgeCSS with an array of filenames or [globs](https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer). These files can be HTML, Pug, Blade, etc.

```
purgecss --css css/app.css --content src/index.html src/**/*.js
```

### --config

You can use the CLI with a [configuration file](/configuration.md). Use `--config` or `-c` with the path to the config file.

```
purgecss --config ./purgecss.config.js
```

### --out

By default, the CLI outputs the result in the console. If you wish to return the CSS as files, specify the directory to write the purified CSS files to.

```
purgecss --css css/app.css --content src/index.html src/**/*.js --out build/css/
```

### --whitelist

If you wish to prevent PurgeCSS from removing a specific CSS selector, you can whitelist it.

```
purgecss --css css/app.css --content src/index.html --whitelist classnameToWhitelist
```

## Example

You can see an example [here](https://github.com/FullHuman/purgecss/tree/master/examples/cli/config-file).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://v1.purgecss.com/cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
