パッケージの詳細

postcss-move-props-to-bg-image-query

JetBrains4.4kMIT4.0.0

PostCSS plugin to turn some style declarations into background image query params

postcss, postcss-plugin, postcss plugin

readme

postcss-move-props-to-bg-image-query

PostCSS plugin to turn some style declarations into background image query params. Main purpose - pass parameters from CSS to webpack loaders (eg. svg-transform-loader).

Demo

Input

.img {
  background: url(img.svg); 
  -svg-mixer-fill: red;
  -svg-mixer-stroke: #000;
}

Output

.img {
  background: url(img.svg?fill=red&stroke=%23000);
}

Installation

npm install postcss-move-props-to-bg-image-query

Usage

const { readFileSync } = require('fs');
const postcss = require('postcss');
const moveProps = require('postcss-move-props-to-bg-image-query');

const input = readFileSync('input.css');

postcss()
  .use(moveProps())
  .process(input)
  .then(result => {
    console.log(result.css);
  });

Via postcss.config.js

const moveProps = require('postcss-move-props-to-bg-image-query');

module.exports = {
  plugins: [
    moveProps()
  ]
}

Configuration

match

Type: string | RegExp | Array<string | RegExp>
Default: '-svg-mixer-*'

Filter which declarations should be transformed. Could be a string (glob pattern), RegExp or array of them.

computeCustomProps

Type: PostCSS plugin instance

You can use CSS custom properties (eg. -svg-mixer-fill: var(--color);) in values by providing corresponding PostCSS plugin, postcss-custom-properties for example:

const moveProps = require('postcss-move-props-to-bg-image-query');
const customProps = require('postcss-custom-properties');

module.exports = {
  plugins: [
    moveProps({
      computeCustomProps: customProps({ preserve: false })
    })
  ]
}

transform

Type: function(decl: {name: string, value: string}): {name: string, value: string}

Declaration-to-query param transform function. Accepts an object with name and value fields and should return object with the same structure. By default strips -svg-mixer- in declaration name, eg. -svg-mixer-fill: red turns into ?fill=red. Declaration value will be URL encoded.

LICENSE

MIT

更新履歴

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2020-04-01)

Bug Fixes

  • detect PostCSS processor properly (c2c3bec)

Features

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean (35c3a81)

BREAKING CHANGES

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean

3.0.0 (2020-04-01)

Bug Fixes

  • detect PostCSS processor properly (c2c3bec)

Features

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean (35c3a81)

BREAKING CHANGES

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean

2.0.0 (2020-01-24)

Bug Fixes

  • detect PostCSS processor properly (c2c3bec)

Features

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean (35c3a81)

BREAKING CHANGES

  • computeCustomProps now accepts only PostCSS plugin instance instead of boolean

1.0.2 (2019-05-21)

Bug Fixes

  • detect PostCSS processor properly (c2c3bec)

1.0.1 (2019-04-27)

Note: Version bump only for package postcss-move-props-to-bg-image-query

1.0.0 (2019-02-08)

Bug Fixes

  • prevent double parsing in custom when compute custom props (a3c04ab)

Chores

  • change default props transformer (c1cb3ba)

BREAKING CHANGES

  • change default prop to move from -svg-* to -svg-mixer-*

0.3.1 (2019-02-08)

Bug Fixes

  • encode css functions properly (b8f8681)

0.3.0 (2019-02-08)

Features

  • add ability to compute CSS custom properties (f13564b)

0.2.8 (2018-12-05)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.7 (2018-10-29)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.6 (2018-10-29)

Bug Fixes

  • refer to license file in readme (e34a289)

0.2.5 (2018-09-15)

Bug Fixes

0.2.4 (2018-08-20)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.3 (2018-06-13)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.2 (2018-05-11)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.1 (2018-04-28)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.2.0 (2018-04-21)

Features

  • handle super complex cases (a5fceb9)
  • pass object<{ name, value }> to transformer instead of declaration (512fc03)

0.1.2 (2018-04-13)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.1.1 (2018-04-13)

Note: Version bump only for package postcss-move-props-to-bg-image-query

0.1.0 (2018-04-13)

Features