1.0.6 • Published 2 years ago

postcss-short-native-vars v1.0.6

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
2 years ago

PostCSS short-native-vars

NPM Version Build Status Support Chat

PostCSS short-native-vars lets you ... in CSS.

:root {
	$test-size: 20px;
	$test-2-size: 10px;
	$test-color: #000;
	$test-3: orange;
	--var: 12px;
}

.test {
	$value: 123px;
	width: calc($test-size * 2 * $test-2-size);
	color: $test-color;
	height: $value;
}

.test-2 {
	width: $test-size;
	height: $test-size;
	color: red;
	background-color: $orange;
}
 

/* becomes */
 
:root {
	--test-size: 20px;
	--test-2-size: 10px;
	--test-color: #000;
	--test-3: orange;
	--var: 12px;
}

.test {
	--value: 123px;
	width: calc(var(--test-size) * 2 * var(--test-2-size));
	color: var(--test-color);
	height: var(--value);
}

.test-2 {
	width: var(--test-size);
	height: var(--test-size);
	color: red;
	background-color: var(--orange);
}
 

Usage

Add PostCSS short-native-vars to your project:

npm install postcss-short-native-vars --save-dev

Use PostCSS short-native-vars to process your CSS:

const postcssShortNativeVars = require('postcss-short-native-vars');

postcssShortNativeVars.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssShortNativeVars = require('postcss-short-native-vars');

postcss([
  postcssShortNativeVars(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS short-native-vars runs in all Node environments, with special instructions for:

NodePostCSS CLIWebpackCreate React AppGulpGrunt

Options

...