# postcss-merge-rules-plus

> PostCSS plugin for combining css rules (selectors) that have fully/partially identical declarations

Latest version **2.0.0** (published 2022-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-merge-rules-plus
pnpm add postcss-merge-rules-plus
yarn add postcss-merge-rules-plus
bun add postcss-merge-rules-plus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-02-09 |
| First published | 2021-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 4 |
| Unpacked size | 46.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | HeyMarco |
| Maintainers | heymarco |
| Keywords | postcss, css, postcss-plugin, postcss-merge-rules-plus |

## Links

- npm: https://www.npmjs.com/package/postcss-merge-rules-plus
- Repository: https://github.com/heyymarco/postcss-merge-rules-plus
- Homepage: https://github.com/heyymarco/postcss-merge-rules-plus#readme
- Issues: https://github.com/heyymarco/postcss-merge-rules-plus/issues
- npm.io page: https://npm.io/package/postcss-merge-rules-plus

## Dependencies (4)

- [caniuse-api](https://npm.io/package/caniuse-api.md) ^3.0.0
- [browserslist](https://npm.io/package/browserslist.md) ^4.19.1
- [postcss-selector-parser](https://npm.io/package/postcss-selector-parser.md) ^6.0.9
- [cssnano-util-same-parent](https://npm.io/package/cssnano-util-same-parent.md) ^4.0.1

## 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

- 2.0.0 (latest) — 2022-02-09
- 1.0.2 — 2021-03-27
- 1.0.1 — 2021-02-05
- 1.0.0 — 2021-02-04

## README

# postcss-merge-rules-plus

[PostCSS] plugin for combining css rules (selectors) that have fully/partially identical declarations.

[PostCSS]: https://github.com/postcss/postcss

## Features
* Combines selectors with fully identical rules.
* Combines selectors with partially identical rules.
* Combines selectors with the same selector declaration.

## Example

### Input
```css
.a { position: absolute; display: block; color: red; background: pink; }
.b { position: absolute; display: block; }
.c { position: absolute; display: inline; color: red; background: pink; opacity: 0.5; }
.d { position: absolute; display: block; opacity: 0.5; z-index: 2; text-align: center; }
```

### Output
```css
.a, .b, .c, .d { position: absolute; }
.a, .b, .d { display: block; }
.a, .c { color: red; background: pink; }
.c, .d { opacity: 0.5; }
.c { display: inline; }
.d { z-index: 2; text-align: center; }
```

## Usage

**Step 1:** Install plugin:

```sh
npm install --save-dev postcss postcss-merge-rules-plus
```

**Step 2:** Check you project for existed PostCSS config: `postcss.config.js`
in the project root, `"postcss"` section in `package.json`
or `postcss` in bundle config.

If you do not use PostCSS, add it according to [official docs]
and set this plugin in settings.

**Step 3:** Add the plugin to plugins list:

```diff
module.exports = {
  plugins: [
+   require('postcss-merge-rules-plus'),
    require('autoprefixer')
  ]
}
```

[official docs]: https://github.com/postcss/postcss#usage

## Usage

```es6
import { src, dest } from 'gulp';
import gutil         from 'gulp-util';
import postcss       from 'gulp-postcss';
import mergeRulePlus from 'postcss-merge-rules-plus';



src('test3.css')
.pipe(
    postcss(/*plugins:*/[
        mergeRulePlus()
    ])
)
.on('error', gutil.log)
.pipe(dest('test/'))
;
```

## Please Support Us
A lot of coffee has been spent for making this plugins.
Please buy me a cup of coffee to support me continue to develop & improve this application.
Visit: [ko-fi.com](https://ko-fi.com/heymarco)

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

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