Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-external-vars

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-external-vars

PostCSS plugin for injecting external variables to your CSS

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

postcss-external-vars Build Status

PostCSS plugin for injecting external variables to your CSS.

/* Input example */
.foo {
  color: $color.primary;
}
/* Output example */
.foo {
  color: #bada55;
}

Install

$ npm install postcss-external-vars

Usage

const externalVars = require('postcss-external-vars');

const data = {
	color: {
		primary: '#bada55',
		background: '#1337af'
	}
};

const css = '.foo {color: $color.primary}';

// Use stand-alone:
const result = externalVars.process(css, {data}).css;
//=> '.foo {color: #bada55}'

// Or as PostCSS plugin:
const postcss = require('postcss');

const result = postcss([externalVars({data})]).process(css).css;
//=> '.foo {color: #bada55}'

Check PostCSS docs out for examples in your preferred environment.

API

externalVars([opts])

opts
data

Type: object
Required

An object of properties to be used within your CSS.

prefix

Type: string
Default: $

A prefix for variable names. May contain several characters.

externalVars.tester([opts])

Returns a function that will accept string to check if it contains any variables and return boolean. Useful to filter your css declarations before processing.

Options are the same.

externalVars.matcher([opts])

Returns a function that will accept string and return an array of all the matched variable names within it.

Options are the same.

License

MIT © Dmitriy Sobolev

Keywords

FAQs

Package last updated on 15 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc