postcss-custom-prop-fallbacks

1.0.4 • Public • Published

postcss-custom-prop-fallbacks

Provides fallbacks for custom properties set in :root. The plugin does not remove the original rule that uses the custom property, but rather places a fallback on the line above for browsers that don't recognize the feature. See the example below.

Install

npm install --save-dev postcss-custom-prop-fallbacks

Usage

Postcss.config.js

const customPropFallbacks = require('postcss-custom-prop-fallbacks');
 
module.exports = {
  plugins: [customPropFallbacks],
};

The following input:

:root {
  --gutter: 1.5rem;
  --brand-primary: #002878;
}
 
.some-element {
  background-color: var(--brand-primary);
  margin-right: calc(var(--gutter) * 1.3333);
}

Will produce the following:

:root {
  --gutter: 1.5rem;
  --brand-primary: #002878;
}
 
.some-element {
  background-color: #002878;
  background-color: var(--brand-primary);
  margin-right: calc(1.5rem * 1.3333);
  margin-right: calc(var(--gutter) * 1.3333);
}

Package Sidebar

Install

npm i postcss-custom-prop-fallbacks

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

145 kB

Total Files

37

Last publish

Collaborators

  • johnwatkins0