postcss-custom-properties

WebJar for postcss-custom-properties

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

postcss-custom-properties
Последняя версия

Последняя версия

6.3.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

postcss-custom-properties
WebJar for postcss-custom-properties
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/postcss/postcss-custom-properties

Скачать postcss-custom-properties

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/postcss-custom-properties/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>postcss-custom-properties</artifactId>
    <version>6.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-custom-properties/
implementation 'org.webjars.npm:postcss-custom-properties:6.3.1'
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-custom-properties/
implementation ("org.webjars.npm:postcss-custom-properties:6.3.1")
'org.webjars.npm:postcss-custom-properties:jar:6.3.1'
<dependency org="org.webjars.npm" name="postcss-custom-properties" rev="6.3.1">
  <artifact name="postcss-custom-properties" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='postcss-custom-properties', version='6.3.1')
)
libraryDependencies += "org.webjars.npm" % "postcss-custom-properties" % "6.3.1"
[org.webjars.npm/postcss-custom-properties "6.3.1"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : balanced-match jar [1.0.0,2)
org.webjars.npm : postcss jar [6.0.18,7)

Модули Проекта

Данный проект не имеет модулей.

PostCSS Custom Properties PostCSS

NPM Version CSS Standard Status Build Status Support Chat

PostCSS Custom Properties lets you use Custom Properties in CSS, following the CSS Custom Properties specification.

'Can I use' table

:root {
  --color: red;
}

h1 {
  color: var(--color);
}

/* becomes */

:root {
  --color: red;
}

h1 {
  color: red;
  color: var(--color);
}

Note: This plugin only processes variables that are defined in the :root selector.

Usage

Add PostCSS Custom Properties to your project:

npm install postcss-custom-properties --save-dev

Use PostCSS Custom Properties to process your CSS:

const postcssCustomProperties = require('postcss-custom-properties');

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

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssCustomProperties = require('postcss-custom-properties');

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

PostCSS Custom Properties runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

preserve

The preserve option determines whether Custom Properties and properties using custom properties should be preserved in their original form. By default, both of these are preserved.

postcssCustomProperties({
  preserve: false
});
:root {
  --color: red;
}

h1 {
  color: var(--color);
}

/* becomes */

h1 {
  color: red;
}

importFrom

The importFrom option specifies sources where Custom Properties can be imported from, which might be CSS, JS, and JSON files, functions, and directly passed objects.

postcssCustomProperties({
  importFrom: 'path/to/file.css' // => :root { --color: red }
});
h1 {
  color: var(--color);
}

/* becomes */

h1 {
  color: red;
}

Multiple sources can be passed into this option, and they will be parsed in the order they are received. JavaScript files, JSON files, functions, and objects will need to namespace Custom Properties using the customProperties or custom-properties key.

postcssCustomProperties({
  importFrom: [
    'path/to/file.css',   // :root { --color: red; }
    'and/then/this.js',   // module.exports = { customProperties: { '--color': 'red' } }
    'and/then/that.json', // { "custom-properties": { "--color": "red" } }
    {
      customProperties: { '--color': 'red' }
    },
    () => {
      const customProperties = { '--color': 'red' };

      return { customProperties };
    }
  ]
});

See example imports written in CSS, JS, and JSON.

exportTo

The exportTo option specifies destinations where Custom Properties can be exported to, which might be CSS, JS, and JSON files, functions, and directly passed objects.

postcssCustomProperties({
  exportTo: 'path/to/file.css' // :root { --color: red; }
});

Multiple destinations can be passed into this option, and they will be parsed in the order they are received. JavaScript files, JSON files, and objects will need to namespace Custom Properties using the customProperties or custom-properties key.

const cachedObject = { customProperties: {} };

postcssCustomProperties({
  exportTo: [
    'path/to/file.css',   // :root { --color: red; }
    'and/then/this.js',   // module.exports = { customProperties: { '--color': 'red' } }
    'and/then/this.mjs',  // export const customProperties = { '--color': 'red' } }
    'and/then/that.json', // { "custom-properties": { "--color": "red" } }
    'and/then/that.scss', // $color: red;
    cachedObject,
    customProperties => {
      customProperties    // { '--color': 'red' }
    }
  ]
});

See example exports written to CSS, JS, MJS, JSON and SCSS.

org.webjars.npm

PostCSS

PostCSS and plugins based on it

Версии библиотеки

Версия
6.3.1
6.1.0