{"id":13508872,"url":"https://github.com/pascalduez/postcss-apply","last_synced_at":"2025-04-04T06:09:52.237Z","repository":{"id":57742119,"uuid":"41434247","full_name":"pascalduez/postcss-apply","owner":"pascalduez","description":"PostCSS plugin enabling custom properties sets references","archived":false,"fork":false,"pushed_at":"2023-10-13T06:35:29.000Z","size":549,"stargazers_count":164,"open_issues_count":9,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-25T04:59:40.357Z","etag":null,"topics":["css","postcss"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pascalduez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-08-26T15:40:55.000Z","updated_at":"2025-02-10T15:11:49.000Z","dependencies_parsed_at":"2024-01-13T20:37:30.825Z","dependency_job_id":"1a4aa0d9-dc4a-4fc9-9b62-5e3c8e283013","html_url":"https://github.com/pascalduez/postcss-apply","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalduez%2Fpostcss-apply","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalduez%2Fpostcss-apply/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalduez%2Fpostcss-apply/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascalduez%2Fpostcss-apply/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pascalduez","download_url":"https://codeload.github.com/pascalduez/postcss-apply/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246193267,"owners_count":20738452,"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","postcss"],"created_at":"2024-08-01T02:00:59.713Z","updated_at":"2025-04-04T06:09:52.195Z","avatar_url":"https://github.com/pascalduez.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# postcss-apply\n\n[![CSS Standard Status][css-image]][css-url]\n[![npm version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][codecov-image]][codecov-url]\n\n\n\u003e [PostCSS] plugin enabling custom property sets references\n\nRefer to [`postcss-custom-properties`](https://github.com/postcss/postcss-custom-properties#postcss-custom-properties-) for DOMless limitations.\n\n\n## Web Platform status\n\nSpec (editor's draft): https://tabatkins.github.io/specs/css-apply-rule  \nBrowser support: https://www.chromestatus.com/feature/5753701012602880  \n\n:warning: The `@apply` rule and custom property sets most likely won't get any more support from browser vendors as the spec is yet considered deprecated and [alternative solutions](https://tabatkins.github.io/specs/css-shadow-parts) are being discussed.  \nRefer to following links for more infos:\n  * https://discourse.wicg.io/t/needed-new-champion-for-css-apply-rule/2012\n  * https://github.com/w3c/webcomponents/issues/300#issuecomment-276210974  \n  * http://www.xanthir.com/b4o00\n  * https://github.com/w3c/csswg-drafts/issues/1047\n  * https://chromium.googlesource.com/chromium/src/+/5874fca7324e4523a4bdecc8999bdadfdb6c4eff\n\n\n## Installation\n\n```\nnpm install postcss-apply --save-dev\n```\n\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst postcss = require('postcss');\nconst apply = require('postcss-apply');\n\nlet input = fs.readFileSync('input.css', 'utf8');\n\npostcss()\n  .use(apply)\n  .process(input)\n  .then(result =\u003e {\n    fs.writeFileSync('output.css', result.css);\n  });\n```\n\n## Examples\n\n### In CSS declared sets\n\n```css\n/* input */\n\n:root {\n  --toolbar-theme: {\n    background-color: rebeccapurple;\n    color: white;\n    border: 1px solid green;\n  };\n}\n\n.Toolbar {\n  @apply --toolbar-theme;\n}\n```\n\n```css\n/* output */\n\n.Toolbar {\n  background-color: rebeccapurple;\n  color: white;\n  border: 1px solid green;\n}\n```\n\n### In JS declared sets\n\n```js\nconst themes = {\n  /* Set names won't be transformed, just `--` will be prepended. */\n  'toolbar-theme': {\n    /* Declaration properties can either be camel or kebab case. */\n    backgroundColor: 'rebeccapurple',\n    color: 'white',\n    border: '1px solid green',\n  },\n};\n\n[...]\npostcss().use(apply({ sets: themes }))\n[...]\n```\n\n```css\n/* input */\n\n.Toolbar {\n  @apply --toolbar-theme;\n}\n```\n\n```css\n/* output */\n\n.Toolbar {\n  background-color: rebeccapurple;\n  color: white;\n  border: 1px solid green;\n}\n```\n\n## options\n\n### `preserve`\ntype: `Boolean`  \ndefault: `false`  \nAllows for keeping resolved declarations and `@apply` rules alongside.\n\n### `sets`  \ntype: `{ [customPropertyName: string]: Object | string }`  \ndefault: `{}`  \nAllows you to pass an object or string of custom property sets for `:root`.\nThese definitions will be prepended, in such overridden by the one declared in CSS if they share the same name.\nThe keys are automatically prefixed with the CSS `--` to make it easier to share sets in your codebase.\n\n\n## Credits\n\n* [Pascal Duez](https://github.com/pascalduez)\n\n\n## Licence\n\npostcss-apply is [unlicensed](http://unlicense.org/).\n\n\n\n[PostCSS]: https://github.com/postcss/postcss\n\n[css-url]: https://cssdb.org#rejected\n[css-image]: https://img.shields.io/badge/cssdb-rejected-red.svg?style=flat-square\n[npm-url]: https://www.npmjs.org/package/postcss-apply\n[npm-image]: http://img.shields.io/npm/v/postcss-apply.svg?style=flat-square\n[travis-url]: https://travis-ci.org/pascalduez/postcss-apply?branch=master\n[travis-image]: http://img.shields.io/travis/pascalduez/postcss-apply.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/pascalduez/postcss-apply\n[codecov-image]: https://img.shields.io/codecov/c/github/pascalduez/postcss-apply.svg?style=flat-square\n[spec]: https://tabatkins.github.io/specs/css-apply-rule\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascalduez%2Fpostcss-apply","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpascalduez%2Fpostcss-apply","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascalduez%2Fpostcss-apply/lists"}