{"id":15171928,"url":"https://github.com/xettri/postcss-remove-duplicate-values","last_synced_at":"2026-01-24T07:04:49.382Z","repository":{"id":230289896,"uuid":"778680856","full_name":"xettri/postcss-remove-duplicate-values","owner":"xettri","description":"A PostCSS plugin that removes duplicate CSS property values within rules, optimizing stylesheet size and improving maintainability.","archived":false,"fork":false,"pushed_at":"2024-03-29T22:23:44.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T19:28:51.067Z","etag":null,"topics":["css","npm-package","postcss","postcss-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/postcss-remove-duplicate-values","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xettri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-28T07:29:59.000Z","updated_at":"2024-03-29T22:12:22.000Z","dependencies_parsed_at":"2024-04-02T18:00:42.784Z","dependency_job_id":null,"html_url":"https://github.com/xettri/postcss-remove-duplicate-values","commit_stats":null,"previous_names":["xettri/postcss-remove-duplicate-values"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xettri%2Fpostcss-remove-duplicate-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xettri%2Fpostcss-remove-duplicate-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xettri%2Fpostcss-remove-duplicate-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xettri%2Fpostcss-remove-duplicate-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xettri","download_url":"https://codeload.github.com/xettri/postcss-remove-duplicate-values/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239483870,"owners_count":19646426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","npm-package","postcss","postcss-plugin"],"created_at":"2024-09-27T09:21:34.751Z","updated_at":"2026-01-24T07:04:49.374Z","avatar_url":"https://github.com/xettri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [postcss][git_url]-remove-duplicate-values\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/postcss-remove-duplicate-values?activeTab=readme\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/postcss-remove-duplicate-values?style=flat-square\u0026colorA=000000\u0026colorB=8338EC\" alt=\"npm version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/xettri/postcss-remove-duplicate-values/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=000000\u0026colorB=8338EC\" alt=\"license\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e **Smart PostCSS plugin that removes duplicate CSS properties, reduces bundle size, and improves CSS maintainability.**\n\n## ✨ What It Does?\n\nAutomatically removes duplicate CSS properties from your stylesheets while keeping the most important ones. Perfect for cleaning up CSS and improving performance.\n\n### 🎯 Key Features\n\n- **🧹 Removes duplicate properties** (keeps the last one)\n- **⚡ Handles `!important` declarations** intelligently\n- **🎨 Supports vendor prefixes** and modern CSS\n- **🎯 Filters specific selectors** (optional)\n- **🗑️ Cleans empty rules** (configurable)\n- **🚀 Zero configuration** needed\n\n## 🚀 Quick Start\n\n### 1. Install\n\n```bash\nnpm install postcss-remove-duplicate-values --save-dev\n# or\npnpm add postcss-remove-duplicate-values -D\n# or\nyarn add postcss-remove-duplicate-values -D\n```\n\n### 2. Use in PostCSS\n\n```js\n// postcss.config.js\nmodule.exports = {\n  plugins: [require('postcss-remove-duplicate-values')],\n};\n```\n\n### 3. That's it! 🎉\n\nThe plugin automatically removes duplicates from your CSS.\n\n## 📖 Examples\n\n### Basic Duplicate Removal\n\n```css\n/* Before */\n.button {\n  color: red;\n  color: blue;\n  margin: 10px;\n  margin: 20px;\n}\n\n/* After */\n.button {\n  color: blue;\n  margin: 20px;\n}\n```\n\n### `!important` Handling\n\n```css\n/* Before */\n.button {\n  color: red !important;\n  color: blue;\n  font-weight: normal;\n  font-weight: bold !important;\n}\n\n/* After */\n.button {\n  color: red !important;\n  font-weight: bold !important;\n}\n```\n\n### Vendor Prefixes\n\n```css\n/* Before */\n.button {\n  transform: translateX(40px);\n  -webkit-transform: translateX(10px);\n  -moz-transform: translateX(10px);\n  transform: translateX(10px);\n}\n\n/* After */\n.button {\n  /* Plugin removes duplicate 'transform' properties, keeping the last one */\n  /* Vendor prefixes are preserved */\n  -webkit-transform: translateX(10px);\n  -moz-transform: translateX(10px);\n  transform: translateX(10px);\n}\n```\n\n## ⚙️ Configuration Options\n\nBefore applying the plugin, you can configure the following options:\n\n| Option                            | Type                                                | Default     |\n| --------------------------------- | --------------------------------------------------- | ----------- |\n| [`selector`](#selector)           | `(selector: string) =\u003e boolean \\| string \\| RegExp` | `undefined` |\n| [`preserveEmpty`](#preserveempty) | `boolean`                                           | `false`     |\n\n### selector\n\nFilter which CSS selectors to process.\n\n```js\n// Only process .button selectors\nremoveDuplicateValues({\n  selector: '.button',\n});\n\n// Process selectors matching regex\nremoveDuplicateValues({\n  selector: /^\\.btn-/,\n});\n\n// Custom function\nremoveDuplicateValues({\n  selector: selector =\u003e selector.includes('button'),\n});\n```\n\n### preserveEmpty\n\nKeep or remove empty CSS rules.\n\n```js\n// Remove empty rules (default)\nremoveDuplicateValues({\n  preserveEmpty: false,\n});\n\n// Keep empty rules\nremoveDuplicateValues({\n  preserveEmpty: true,\n});\n```\n\n## 🔧 Advanced Usage\n\n### With PostCSS API\n\n```js\nconst postcss = require('postcss');\nconst removeDuplicateValues = require('postcss-remove-duplicate-values');\n\nconst css = `\n.button {\n  color: red;\n  color: blue;\n}`;\n\npostcss([removeDuplicateValues()])\n  .process(css)\n  .then(result =\u003e {\n    console.log(result.css);\n    // Output: .button { color: blue; }\n  });\n```\n\n### With Build Tools\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: [\n          'style-loader',\n          'css-loader',\n          {\n            loader: 'postcss-loader',\n            options: {\n              plugins: [require('postcss-remove-duplicate-values')],\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n## 📚 More Examples\n\n### Selector Filtering\n\n```css\n/* Input CSS */\n.container {\n  color: red;\n  color: blue;\n}\n.button {\n  margin: 10px;\n  margin: 20px;\n}\n\n/* With selector: '.container' */\n.container {\n  color: blue;\n}\n.button {\n  margin: 10px;\n  margin: 20px; /* Not processed */\n}\n```\n\n### Empty Rule Handling\n\n```css\n/* Input CSS */\n.empty-rule {\n}\n.button {\n  color: blue;\n}\n\n/* With preserveEmpty: false */\n.button {\n  color: blue;\n}\n/* .empty-rule removed */\n\n/* With preserveEmpty: true */\n.empty-rule {\n}\n.button {\n  color: blue;\n}\n```\n\n## 🎮 Try It Live!\n\n**Test the plugin in real-time with our interactive playground:**\n\n[🎮 **Try the Playground** →](https://xettri.github.io/postcss-remove-duplicate-values)\n\n### What You Can Do in the Playground:\n\n- ✨ **Test CSS processing** in real-time\n- 🎯 **Experiment with options** (selector filtering, empty rule preservation)\n- 📚 **Try pre-built examples** for common scenarios\n- 📊 **See live statistics** of duplicate removal results\n- 🎨 **Understand plugin behavior** through interactive examples\n\n\u003cbr\u003e\n\n**Made with ❤️ by [Bharat Rawat](https://bharatrawat.com)**\n\n[PostCSS Remove Duplicate Values]: https://github.com/xettri/postcss-remove-duplicate-values\n[npm_url]: https://www.npmjs.com/package/postcss-remove-duplicate-values\n[git_url]: https://github.com/xettri/postcss-remove-duplicate-values\n[PostCSS]: https://github.com/postcss/postcss\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxettri%2Fpostcss-remove-duplicate-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxettri%2Fpostcss-remove-duplicate-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxettri%2Fpostcss-remove-duplicate-values/lists"}