Skip to content

Provide fallback values for properties without having duplicate declarations with PostCSS

Notifications You must be signed in to change notification settings

MadLittleMods/postcss-fallback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version Build Status

PostCSS Fallback

PostCSS plugin to provide fallback values for properties without having duplicate declarations.

Works great with the stylelint rule-no-duplicate-properties rule.

Install

npm install postcss-fallback --save-dev

Usage

Basic Example

var postcss = require('postcss');
var fallback = require('postcss-fallback');

var fs = require('fs');

var mycss = fs.readFileSync('input.css', 'utf8');

// Process your CSS with postcss-fallback
var output = postcss([
		fallback(/*options*/)
	])
	.process(mycss)
	.css;

console.log(output);

Input:

.foo {
	display: fallback(flex, inline-block);
	width: fallback(45vh, 450px);

	background-color: fallback(rgba(0, 0, 0, 0.5), #555555);
	foo: fallback(bar, baz, qux, corge);
}

Output:

.foo {
	display: inline-block;
	display: flex;
	width: 450px;
	width: 45vh;

	background-color: #555555;
	background-color: rgba(0, 0, 0, 0.5);
	foo: corge;
	foo: qux;
	foo: baz;
	foo: bar;
}

Options

  • keyword: string - The fallback function keyword.
    • Default: 'fallback'

Testing

npm test

About

Provide fallback values for properties without having duplicate declarations with PostCSS

Resources

Stars

Watchers

Forks

Packages

No packages published