https://github.com/tiaanduplessis/css-dedoupe
🙌 Remove duplicate properties and declarations from your CSS
https://github.com/tiaanduplessis/css-dedoupe
css dedoupe deduplication prune
Last synced: 2 months ago
JSON representation
🙌 Remove duplicate properties and declarations from your CSS
- Host: GitHub
- URL: https://github.com/tiaanduplessis/css-dedoupe
- Owner: tiaanduplessis
- License: mit
- Created: 2017-05-12T14:53:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-12T23:27:33.000Z (over 5 years ago)
- Last Synced: 2025-07-01T11:52:05.023Z (3 months ago)
- Topics: css, dedoupe, deduplication, prune
- Language: JavaScript
- Size: 223 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
css-dedoupe
Remove duplicate properties and declarations from your CSS
Table of Contents
Table of Contents
## About
[](https://greenkeeper.io/)
This is a basic module that walks a AST built with [reworkcss](github.com/reworkcss/css) and removes duplicate CSS properties associated with a specific selector. Only keeping the most recent.
## Install
```sh
$ npm install --save css-dedoupe
# OR
$ yarn add css-dedoupe
```
## Usage
```js
const cssDedoupe = require('css-dedoupe')
const cssStr = '.float-right {float: right;}.float-right {float: right;}'
console.log(cssDedoupe(cssStr)) // '.float-right{float:right}'
```
## CLI
```sh
$ css-dedoupe input.css output.css
```
Or if you would like to modify the input file directly:
```sh
$ css-dedoupe inputAndOutput.css
```
## Issues
- Currently only supports top level declartions e.g. does not dedoupe declartions in media queries.
- The module makes no attempt to format the css after dedouping. Use modules like [csscomb](https://github.com/csscomb/csscomb.js) for this.
## Contribute
Contributions are welcome. Please open up an issue or create PR if you would like to help out.
Note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
Licensed under the MIT License.