# postcss-filter-plugins

> Exclude/warn on duplicated PostCSS plugins.

Latest version **4.0.0** (published 2026-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-filter-plugins
pnpm add postcss-filter-plugins
yarn add postcss-filter-plugins
bun add postcss-filter-plugins
```

## Health

**Score 45/100 (D)** — status: active.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-06-02 |
| First published | 2015-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | MoOx |
| Maintainers | beneb, moox, ryanzim |
| Keywords | css, postcss, postcss-plugin |

## Links

- npm: https://www.npmjs.com/package/postcss-filter-plugins
- Repository: https://github.com/postcss/postcss-filter-plugins
- Issues: https://github.com/postcss/postcss-filter-plugins/issues
- npm.io page: https://npm.io/package/postcss-filter-plugins

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-06-02
- 2.0.3 — 2018-05-22
- 3.0.1 — 2018-05-18
- 3.0.0 — 2018-01-09
- 2.0.2 — 2016-10-03
- 2.0.1 — 2016-07-12
- 2.0.0 — 2015-09-04
- 1.0.1 — 2015-09-01
- 1.0.0 — 2015-07-20

## README

# postcss-filter-plugins

[![GitHub package.json version](https://img.shields.io/github/package-json/v/postcss/postcss-filter-plugins) ![npm downloads](https://img.shields.io/npm/dm/postcss-filter-plugins)](https://www.npmjs.com/package/postcss-filter-plugins)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/postcss/postcss-filter-plugins/test.yml)](https://github.com/postcss/postcss-filter-plugins/actions)
[![License](https://img.shields.io/github/license/postcss/postcss-filter-plugins)](https://github.com/postcss/postcss-filter-plugins)

> Exclude/warn on duplicated PostCSS plugins.

## Install

```console
npm install postcss-filter-plugins
```

## Example

Note that this plugin does not actually transform your CSS; instead, it ensures
that plugins in the PostCSS instance are not duplicated. It is intended to be
used by plugin packs such as [cssnano](http://cssnano.co).

```js
const counter = () => ({
  postcssPlugin: "counter",
  Once(css) {
    css.walkDecls("foo", (decl) => {
      let value = parseInt(decl.value, 10);
      value += 1;
      decl.value = String(value);
    });
  },
});
counter.postcss = true;

const css = "h1 { foo: 1 }";
const out = postcss([filter(), counter(), counter()]).process(css).css;

console.log(out);
// => h1 { foo: 2 }
// Note that you will get a PostCSS warning in the message registry
```

## API

### filterPlugins([options])

#### options

##### direction

Type: `string`  
Default: `'both'`

Pass `'forward'`, `'backward'`, or `'both'` to customise the direction in which the
plugin will look in the plugins array. See the tests for examples on how this
works.

```js
postcss([ filter({
    direction: 'forward'
}) ]).process(css).css);
```

##### exclude

Type: `array`  
Default: `[] (empty)`

Plugins that should be excluded from the filter. Pass an array of plugin names.

```js
postcss([ filter({
    exclude: ['postcss-cssstats']
}) ]).process(css).css);
```

##### silent

Type: `boolean`  
Default: `false`

Set this to true to disable the plugin from emitting any PostCSS warnings.

```js
postcss([ filter({
    silent: true
}) ]).process(css).css);
```

##### template

Type: `function`  
Default: `format function`

This function will be passed each PostCSS plugin object. You are expected to
return a string from each call, which is then used to warn the user about her
duplicated plugins.

```js
postcss([ filter({
    template: function (plugin) {
        return 'Duplicate plugin found: ' + plugin.postcssPlugin;
    }
}) ]).process(css).css);
```

## Usage

See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.

## Contributors

Thanks goes to [these wonderful people](https://github.com/postcss/postcss-filter-plugins/graphs/contributors)

## [License](./LICENSE)

---
_Source: https://npm.io/package/postcss-filter-plugins · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
