@notiv/postcss-property-lookup

2.1.1 • Public • Published

postcss-property-lookup Build Status

PostCSS plugin that allows referencing property values without a variable, similar to Stylus.

.Test {
  margin-left: 20px;
  margin-right: @margin-left;
  color: red;
  background: @color url('test.png');
  line-height: 1.5;
  font-size: @(line-height)em;
}
.Test {
  margin-left: 20px;
  margin-right: 20px;
  color: red;
  background: red url('test.png');
  line-height: 1.5;
  font-size: 1.5em;
}

Check the test fixtures for more examples.

Usage

postcss([ require('postcss-property-lookup') ])

See PostCSS docs for examples for your environment.

Installation

$ npm install postcss-property-lookup

Usage

JavaScript

postcss([
  require('postcss-property-lookup')(/* options */),
  // more plugins...
])

TypeScript

///<reference path="node_modules/postcss-property-lookup/.d.ts" />
import postcssPropertyLookup from 'postcss-property-lookup';

postcss([
  postcssPropertyLookup(/* options */),
  // more plugins...
])

Options

logLevel

Type: string: <error|warn>
Required: false
Default: warn

When a lookup cannot be resolved, this specifies whether to throw an error or log a warning. In the case of a warning, the invalid lookup value will be replaced with an empty string.

lookupPattern

Type: RegExp
Required: false
Default: /@\(?([a-z-]+)\)?\b/g

The regular expression by which the property will be searched

For example, to enable working with postcss-inline-media, look up only css-properies @font-size, @color, ...:

{
  lookupPattern: /@([a-z-]+)\b/g;
}

skipUnknown

Type: Boolean
Required: false
Default: true

Skip replace if property was not found.

Package Sidebar

Install

npm i @notiv/postcss-property-lookup

Weekly Downloads

1

Version

2.1.1

License

MIT

Unpacked Size

9.1 kB

Total Files

6

Last publish

Collaborators

  • notiv