postcss-custom-media

WebJar for postcss-custom-media

Лицензия

Лицензия

MIT
Группа

Группа

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

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

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

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

6.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

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

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

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

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

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

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

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

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

Зависимости

compile (1)

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

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

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

PostCSS Custom Media PostCSS

NPM Version CSS Standard Status Build Status Support Chat

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

@custom-media --small-viewport (max-width: 30em);

@media (--small-viewport) {
  /* styles for small viewport */
}

/* becomes */

@media (max-width: 30em) {
  /* styles for small viewport */
}

Usage

Add PostCSS Custom Media to your project:

npm install postcss-custom-media --save-dev

Use PostCSS Custom Media to process your CSS:

const postcssCustomMedia = require('postcss-custom-media');

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

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssCustomMedia = require('postcss-custom-media');

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

PostCSS Custom Media 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 media and atrules using custom media should be preserved in their original form.

@custom-media --small-viewport (max-width: 30em);

@media (--small-viewport) {
  /* styles for small viewport */
}

/* becomes */

@custom-media --small-viewport (max-width: 30em);

@media (max-width: 30em) {
  /* styles for small viewport */
}

@media (--small-viewport) {
  /* styles for small viewport */
}

importFrom

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

postcssCustomMedia({
  importFrom: 'path/to/file.css' // => @custom-selector --small-viewport (max-width: 30em);
});
@media (max-width: 30em) {
  /* styles for small viewport */
}

@media (--small-viewport) {
  /* styles for small viewport */
}

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 media using the customMedia or custom-media key.

postcssCustomMedia({
  importFrom: [
    'path/to/file.css',
    'and/then/this.js',
    'and/then/that.json',
    {
      customMedia: { '--small-viewport': '(max-width: 30em)' }
    },
    () => {
      const customMedia = { '--small-viewport': '(max-width: 30em)' };

      return { customMedia };
    }
  ]
});

exportTo

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

postcssCustomMedia({
  exportTo: 'path/to/file.css' // @custom-media --small-viewport (max-width: 30em);
});

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 media using the customMedia or custom-media key.

const cachedObject = { customMedia: {} };

postcssCustomMedia({
  exportTo: [
    'path/to/file.css',   // @custom-media --small-viewport (max-width: 30em);
    'and/then/this.js',   // module.exports = { customMedia: { '--small-viewport': '(max-width: 30em)' } }
    'and/then/this.mjs',  // export const customMedia = { '--small-viewport': '(max-width: 30em)' } }
    'and/then/that.json', // { "custom-media": { "--small-viewport": "(max-width: 30em)" } }
    cachedObject,
    customMedia => {
      customMedia    // { '--small-viewport': '(max-width: 30em)' }
    }
  ]
});

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

org.webjars.npm

PostCSS

PostCSS and plugins based on it

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

Версия
6.0.0