{"id":20321987,"url":"https://github.com/silvermine/postcss-css-var-fallback","last_synced_at":"2025-04-11T19:10:57.915Z","repository":{"id":38380648,"uuid":"401744442","full_name":"silvermine/postcss-css-var-fallback","owner":"silvermine","description":"PostCSS plugin to insert fallbacks for CSS Custom Properties","archived":false,"fork":false,"pushed_at":"2024-08-23T00:19:02.000Z","size":368,"stargazers_count":1,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T15:04:39.662Z","etag":null,"topics":["css","css-custom-properties","css-variables","postcss"],"latest_commit_sha":null,"homepage":"","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/silvermine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-08-31T15:00:59.000Z","updated_at":"2024-08-23T00:19:06.000Z","dependencies_parsed_at":"2024-08-23T01:44:25.011Z","dependency_job_id":null,"html_url":"https://github.com/silvermine/postcss-css-var-fallback","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvermine%2Fpostcss-css-var-fallback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvermine%2Fpostcss-css-var-fallback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvermine%2Fpostcss-css-var-fallback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvermine%2Fpostcss-css-var-fallback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silvermine","download_url":"https://codeload.github.com/silvermine/postcss-css-var-fallback/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465344,"owners_count":21108244,"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-custom-properties","css-variables","postcss"],"created_at":"2024-11-14T19:18:16.241Z","updated_at":"2025-04-11T19:10:57.894Z","avatar_url":"https://github.com/silvermine.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostCSS CSS Var Fallback\n\n[![NPM Version](https://img.shields.io/npm/v/@silvermine/postcss-css-var-fallback.svg)](https://www.npmjs.com/package/@silvermine/postcss-css-var-fallback)\n[![License](https://img.shields.io/github/license/silvermine/postcss-css-var-fallback.svg)](./LICENSE)\n[![Build Status](https://travis-ci.com/silvermine/postcss-css-var-fallback.svg?branch=main)](https://travis-ci.com/silvermine/postcss-css-var-fallback)\n[![Coverage Status](https://api.travis-ci.com/silvermine/postcss-css-var-fallback.svg?branch=main)](https://coveralls.io/github/silvermine/postcss-css-var-fallback?branch=main)\n[![Dependency Status](https://david-dm.org/silvermine/postcss-css-var-fallback.svg)](https://david-dm.org/silvermine/postcss-css-var-fallback)\n[![Dev Dependency Status](https://david-dm.org/silvermine/postcss-css-var-fallback/dev-status.svg)](https://david-dm.org/silvermine/postcss-css-var-fallback#info=devDependencies\u0026view=table)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n\n[PostCSS] plugin to insert fallbacks for CSS vars.\n\n[PostCSS]: https://github.com/postcss/postcss\n\n```css\n.foo {\n   /* Input example */\n   color: var(--color, #4a6da7);\n}\n```\n\n```css\n.foo {\n   /* Output example */\n   color: #4a6da7;\n   color: var(--color, #4a6da7);\n}\n```\n\n## Usage\n\n**Step 1:** Install plugin:\n\n```sh\nnpm install --save-dev postcss @silvermine/postcss-css-var-fallback\n```\n\n**Step 2:** Check you project for existed PostCSS config: `postcss.config.js`\nin the project root, `\"postcss\"` section in `package.json`\nor `postcss` in bundle config.\n\nIf you do not use PostCSS, add it according to [official docs]\nand set this plugin in settings.\n\n**Step 3:** Add the plugin to plugins list:\n\n```diff\nmodule.exports = {\n  plugins: [\n+   require('@silvermine/postcss-css-var-fallback'),\n    require('autoprefixer')\n  ]\n}\n```\n\n## Limitations\n\nBe aware that this plugin does not add a fallback for declarations with `var` statements\nwhen there is more than one declaration for a given CSS property in a single rule.\n\nFor example, this plugin will not add a fallback for the `var` statement in this case:\n\n```css\n.example {\n   color: red;\n   color: var(--textColor, #333);\n}\n```\n\nThe plugin assumes that the previous `color: red` declaration is a fallback. This prevents\nthe plugin from having to parse the `var(--textColor, #333)` statement and compare the\nfallback there with any other `color:` declaration values. We found that such a check\nimpacted performance enough that it was not worth the cost.\n\nTo avoid incorrect or missing fallbacks, ensure that the CSS that you write does not have\nextraneous/duplicate declarations for the same CSS property.\n\n[official docs]: https://github.com/postcss/postcss#usage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvermine%2Fpostcss-css-var-fallback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilvermine%2Fpostcss-css-var-fallback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvermine%2Fpostcss-css-var-fallback/lists"}