0.1.2 • Published 11 months ago

postcss-plugin-add-encapsulation-selector v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

PostCSS Plugin Add Encapsulation Selector

PostCSS plugin to add encapsulation selector.

This plugin can modify styles with any selector as follows, and can limit them to having the specified selector or being a child element of the specified selector.

Installation

npm install -D postcss-plugin-add-encapsulation-selector

Usage

Please add the following description to the PostCSS configuration file.

module.exports = {
  plugins: [
+   require('postcss-plugin-add-encapsulation-selector', {
+     targetRegexp: /\.target/,
+     capsuleSelector: '.capsule'
+   }),
  ]
}

The style of the selector that matches targetRegexp is limited to having the selector specified by capsuleSelector, or being a child element of capsuleSelector.

- .target{ color: red; } .not-target { color: blue; }
+ .capsule.target, .capsule .target{ color: red; } .not-target { color: blue; }

Options

targetRegexp

  • Type: RegExp
  • Default: /\.+/

A regular expression that matches the selector to be encapsulated.

capsuleSelector

  • Type: string | undefined
  • Default: undefined

The string of the selector used for encapsulation.

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

1 year ago