{"id":19652988,"url":"https://github.com/csstools/postcss-extend-rule","last_synced_at":"2025-05-16T19:04:02.712Z","repository":{"id":35086855,"uuid":"103790620","full_name":"csstools/postcss-extend-rule","owner":"csstools","description":"Use the extend at-rule and functional selectors in CSS","archived":false,"fork":false,"pushed_at":"2024-12-27T18:32:29.000Z","size":291,"stargazers_count":51,"open_issues_count":5,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-02T08:39:05.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jonathantneal.github.io/postcss-extend-rule/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csstools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-09-16T23:38:32.000Z","updated_at":"2024-12-27T18:32:32.000Z","dependencies_parsed_at":"2024-01-08T03:05:39.896Z","dependency_job_id":"de8d5964-40ff-42ef-bce9-5c325be8bad8","html_url":"https://github.com/csstools/postcss-extend-rule","commit_stats":{"total_commits":29,"total_committers":6,"mean_commits":4.833333333333333,"dds":0.5172413793103448,"last_synced_commit":"3e9781d76ddb32100966c1c422b8382cf69c29c5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-extend-rule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-extend-rule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-extend-rule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-extend-rule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csstools","download_url":"https://codeload.github.com/csstools/postcss-extend-rule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253517319,"owners_count":21920826,"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":[],"created_at":"2024-11-11T15:12:50.782Z","updated_at":"2025-05-16T19:04:02.665Z","avatar_url":"https://github.com/csstools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostCSS Extend Rule [\u003cimg src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS\" width=\"90\" height=\"90\" align=\"right\"\u003e][postcss]\n\n[![NPM Version][npm-img]][npm-url]\n[![test](https://github.com/csstools/postcss-extend-rule/actions/workflows/test.yml/badge.svg)](https://github.com/csstools/postcss-extend-rule/actions/workflows/test.yml)\n[\u003cimg alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord\u0026logoColor=white\"\u003e][discord]\n\n[PostCSS Extend Rule] lets you use the `@extend` at-rule and\n[Functional Selectors] in CSS, following the speculative\n[CSS Extend Rules Specification].\n\n```pcss\n%thick-border {\n  border: thick dotted red;\n}\n\n.serious-modal {\n  font-style: normal;\n  font-weight: bold;\n\n  @media (max-width: 240px) {\n    @extend .modal:hover;\n  }\n}\n\n.modal {\n  @extend %thick-border;\n\n  color: red;\n}\n\n.modal:hover:not(:focus) {\n  outline: none;\n}\n\n/* becomes */\n\n.serious-modal {\n  font-style: normal;\n  font-weight: bold;\n}\n\n@media (max-width: 240px) {\n  .serious-modal:not(:focus) {\n    outline: none;\n  }\n}\n\n.modal {\n  border: thick dotted red;\n  color: red;\n}\n\n.modal:hover:not(:focus) {\n  outline: none;\n}\n```\n\n## Usage\n\nAdd [PostCSS Extend Rule] to your project:\n\n```bash\nnpm install postcss postcss-extend-rule --save-dev\n```\n\nUse **PostCSS Extend Rule** to process your CSS:\n\n```js\nconst postcssExtendRule = require('postcss-extend-rule');\n\npostcssExtendRule.process(YOUR_CSS /*, processOptions, pluginOptions */);\n```\n\nOr use it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssExtendRule = require('postcss-extend-rule');\n\npostcss([\n  postcssExtendRule(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n**PostCSS Extend Rule** runs in all Node environments, with special instructions for:\n\n| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |\n| --- | --- | --- | --- | --- | --- |\n\n## Options\n\n### name\n\nThe `name` option determines the at-rule name being used to extend selectors.\nBy default, this name is `extend`, meaning `@extend` rules are parsed.\n\n```js\npostcssExtend({ name: 'postcss-extend' })\n```\n\nIf the `name` option were changed to, say, `postcss-extend`, then only\n`@postcss-extend` at-rules would be parsed.\n\n```pcss\nmain {\n  @postcss-extend .some-rule;\n}\n```\n\n### onFunctionalSelector\n\nThe `onFunctionalSelector` option determines how functional selectors should be\nhandled. Its options are:\n\n- `remove` (default) removes any functional selector\n- `ignore` ignores any functional selector and moves on\n- `warn` warns the user whenever it encounters a functional selector\n- `throw` throws an error if ever it encounters a functional selector\n\n```js\npostcssExtend({ onFunctionalSelector: 'remove' /* default */ })\n```\n\n```pcss\n%this-will-be-removed {}\n```\n\n### onRecursiveExtend\n\nThe `onRecursiveExtend` option determines how recursive extend at-rules should\nbe handled. Its options are:\n\n- `remove` (default) removes any recursive extend at-rules\n- `ignore` ignores any recursive extend at-rules and moves on\n- `warn` warns the user whenever it encounters a recursive extend at-rules\n- `throw` throws an error if ever it encounters a recursive extend at-rules\n\n```js\npostcssExtend({ onRecursiveExtend: 'remove' /* default */ })\n```\n\n```pcss\n.this-will-not-extend-itself {\n  @extend .this-will-not-extend-itself;\n}\n```\n\n### onUnusedExtend\n\nThe `onUnusedExtend` option determines how an unused extend at-rule should be\nhandled. Its options are:\n\n- `remove` (default) removes any unused extend at-rule\n- `ignore` ignores any unused extend at-rule and moves on\n- `warn` warns the user whenever it encounters an unused extend at-rule\n- `throw` throws an error if ever it encounters an unused extend at-rule\n\n```js\npostcssExtend({ onUnusedExtend: 'remove' /* default */ })\n```\n\n```pcss\nmain {\n  @extend .this-selector-does-not-exist-and-will-be-removed;\n}\n```\n\n[git-img]: https://img.shields.io/badge/support-chat-blue.svg\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-img]: https://img.shields.io/npm/v/postcss-extend-rule.svg\n[npm-url]: https://www.npmjs.com/package/postcss-extend-rule\n\n[CSS Extend Rules Specification]: https://jonathantneal.github.io/specs/css-extend-rule/\n[Functional Selectors]: https://jonathantneal.github.io/specs/css-extend-rule/#functional-selector\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Extend Rule]: https://github.com/csstools/postcss-extend-rule\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-extend-rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsstools%2Fpostcss-extend-rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-extend-rule/lists"}