7.0.5 • Published 1 month ago

remap-css v7.0.5

Weekly downloads
246
License
BSD-2-Clause
Repository
github
Last release
1 month ago

remap-css

npm.io npm.io

Remap CSS rules based on declaration value

Usage

npm i remap-css
import remapCss from "remap-css";

const css = await remapCss([{
  css: `
    a {
      color: red;
    }
  `}
], {
  "color: red": "color: blue"
});
// a {
//   color: blue;
// }

API

remapCss(sources, mappings, [opts])

Returns a Promise that resolves to a CSS string.

  • sources: Array Array of sources
    • source: Object
      • css: string A CSS string
      • prefix: string A CSS selector to be prefixed to all output rules
      • match: string A array of plain CSS selectors that prevent a prefix addition on exact match
      • name: string Optional name used in comments
  • mappings: Object CSS declaration value-to-value mapping. The key is either a exact match CSS declaration or a special rule starting with $. The value is the a replacement declaration or a replacement value in the case of a special rule.
  • options: Object
    • indentSize: number Numbers of spaces to indent rules and declarations. Default: 2.
    • indentCss: number Numbers of spaces to indent the output. Default: 0.
    • lineLength: number Number of characters after which to wrap lines. Default: 80.
    • ignoreSelectors: Array of RegExp Regular expressions of selectors to ignore. Default: [].
    • comments: boolean Whether to output comments. Default: false.
    • stylistic: boolean Whether to perform stylistic tweaks on selectors. Default: false.
    • validate: boolean Validate properties and discard ones that fail. Default: false.
    • keep: boolean Retain non-matching declarations in the output. Default: false.

These special mapping keys supported:

  • $border: value: Any occurance of value in a border rule.
  • $background: value Any occurance of value in a background rule.
  • $box-shadow: value Any occurance of value in a box-shadow rule.
  • $value: value: Any occurance of value.

On special rules, only specify the replacement value alone (not the whole declaration).

Related

  • fetch-css - Extract CSS from websites and browser extensions

© silverwind, distributed under BSD licence

7.0.5

1 month ago

7.0.4

2 months ago

7.0.3

10 months ago

7.0.2

12 months ago

7.0.0

1 year ago

7.0.1

1 year ago

5.0.9

3 years ago

5.0.8

3 years ago

5.0.10

3 years ago

5.0.11

3 years ago

5.0.12

3 years ago

5.0.13

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.0.7

3 years ago

5.0.6

3 years ago

5.0.5

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.11.5

4 years ago

4.11.4

4 years ago

4.11.3

4 years ago

4.11.0

4 years ago

4.11.1

4 years ago

4.11.2

4 years ago

4.10.0

4 years ago

4.9.2

4 years ago

4.9.1

4 years ago

4.9.0

4 years ago

4.8.4

4 years ago

4.8.1

4 years ago

4.8.0

4 years ago

4.8.3

4 years ago

4.8.2

4 years ago

4.7.3

4 years ago

4.7.2

4 years ago

4.7.1

4 years ago

4.7.0

4 years ago

4.6.0

4 years ago

4.5.6

4 years ago

4.5.5

4 years ago

4.5.4

4 years ago

4.5.3

4 years ago

4.5.2

4 years ago

4.5.1

4 years ago

4.5.0

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.3

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.3.0

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.2.2

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago