{"id":27882877,"url":"https://github.com/valeriogc/postcss-media-query-pruner","last_synced_at":"2026-02-22T22:33:50.105Z","repository":{"id":290447330,"uuid":"974504544","full_name":"ValerioGc/postcss-media-query-pruner","owner":"ValerioGc","description":"A PostCSS plugin that merges, removes duplicates, and sorts media queries for optimized, lightweight CSS","archived":false,"fork":false,"pushed_at":"2025-04-28T22:23:04.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T06:08:59.139Z","etag":null,"topics":["css","css-optimization","media-queries","postcss","postcss-plugin","sorting"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ValerioGc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T22:08:22.000Z","updated_at":"2025-04-28T22:22:37.000Z","dependencies_parsed_at":"2025-04-28T22:42:36.107Z","dependency_job_id":"e61e8635-dd20-46cd-b477-18c9c0a47861","html_url":"https://github.com/ValerioGc/postcss-media-query-pruner","commit_stats":null,"previous_names":["valeriogc/postcss-media-query-pruner"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValerioGc%2Fpostcss-media-query-pruner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValerioGc%2Fpostcss-media-query-pruner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValerioGc%2Fpostcss-media-query-pruner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValerioGc%2Fpostcss-media-query-pruner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ValerioGc","download_url":"https://codeload.github.com/ValerioGc/postcss-media-query-pruner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252448587,"owners_count":21749495,"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","css-optimization","media-queries","postcss","postcss-plugin","sorting"],"created_at":"2025-05-05T06:09:03.678Z","updated_at":"2026-02-22T22:33:50.038Z","avatar_url":"https://github.com/ValerioGc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postcss-media-query-pruner\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/postcss-media-query-pruner?color=red\u0026label=npm%20version\u0026style=flat-square\" alt=\"npm version\" /\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dt/postcss-media-query-pruner?color=blue\u0026label=npm%20downloads\u0026style=flat-square\" alt=\"npm downloads\" /\u003e\n\u003c/p\u003e\n\n**postcss-media-query-pruner** is a PostCSS plugin that **consolidates** and **cleans up** media queries in your CSS. It merges identical media queries into single blocks, removes duplicate rules, and optionally sorts them in “mobile-first” or “desktop-first” order if enabled through options. It helps reduce CSS file size and improves maintainability by ensuring that media queries are organized and efficient.\n\n\n\u003cbr/\u003e\n\n## 📦 Installation\n\nInstall with npm:\n\n```bash\nnpm install postcss-media-query-pruner --save-dev\n```\n\n## 🔧 Usage\n\nConfigure in your PostCSS setup (e.g., `postcss.config.js` or your build tool):\n\n```js\nimport mediaQueryPruner from 'postcss-media-query-pruner';\n\nmodule.exports = {\n  plugins: [\n    mediaQueryPruner({\n      include: ['*'],      \n      exclude: [],     \n      sortingEnabled: true,          \n      sort: 'mobileFirst', // or 'desktopFirst'\n      logger: {\n        info: msg =\u003e console.log('[Pruner]', msg),\n        error: msg =\u003e console.error('[Pruner]', msg),\n      },\n    }),\n  ],\n};\n```\n\n## ⚙️ Options\n\n| Option            | Type                 | Default        | Description                                                                    |\n|-------------------|----------------------|----------------|--------------------------------------------------------------------------------|\n| `include`         | `string[]`           | `['*']`        | Glob patterns or substrings to include files.                                  |\n| `exclude`         | `string[]`           | `[]`           | Glob patterns or substrings to exclude files.                                  |\n| `sortingEnabled`  | `boolean`            | `false`        | Enable sorting of media queries by width.                                      |\n| `sort`            | `'mobileFirst'` \\| `'desktopFirst'` | `'mobileFirst'` | Sorting strategy: ascending or descending by `min-width`.                    |\n| `logger`          | `{info, error}`      | `console`      | Custom logger for info and error messages.                                     |\n\n\n## 📋 Examples\n\n### 1. Merge \u0026 Deduplicate\n\n**Input:**\n\n```css\n@media (min-width: 600px) {\n  .btn { color: blue; }\n}\n@media (min-width: 600px) {\n  .btn { color: blue; }\n  .card { padding: 1rem; }\n}\n```\n\n**Output:**\n\n```css\n@media (min-width: 600px) {\n  .btn { color: blue; }\n  .card { padding: 1rem; }\n}\n```\n\n### 2. Sorting Enabled (Desktop-first)\n\n**Input:**\n\n```css\n@media (min-width: 300px) { .a { font-size: 14px; } }\n@media (min-width: 800px) { .b { font-size: 16px; } }\n```\n\n**Config:**\n\n```js\nmediaQueryPruner({ sortingEnabled: true, sort: 'desktopFirst' });\n```\n\n**Output:**\n\n```css\n@media (min-width: 800px) { .b { font-size: 16px; } }\n@media (min-width: 300px) { .a { font-size: 14px; } }\n```\n\n### 3. Include/Exclude Patterns\n\n```js\nmediaQueryPruner({\n  include: ['src/components'],\n  exclude: ['legacy.css'],\n});\n```\n\nOnly files in `src/components` will be pruned, skipping any path containing `legacy.css`.\n\n\u003cbr/\u003e \n\n## 🤝 Contributing\n\nContributions welcome! Please open issues or pull requests for bug fixes and features.\n\n## 📄 License\n\nThis project is licensed under the **0BSD** License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriogc%2Fpostcss-media-query-pruner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaleriogc%2Fpostcss-media-query-pruner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriogc%2Fpostcss-media-query-pruner/lists"}