1. postcss-icss-selectors
PostCSS plugin for css modules to local-scope classes and ids
postcss-icss-selectors
Package: postcss-icss-selectors
Created by: css-modules
Last modified: Fri, 24 Jun 2022 10:08:54 GMT
Version: 2.0.3
License: MIT
Downloads: 288,265
Repository: https://github.com/css-modules/postcss-icss-selectors

Install

npm install postcss-icss-selectors
yarn add postcss-icss-selectors

postcss-icss-selectors Build Status

PostCSS plugin for css modules to local-scope classes and ids

Usage

 postcss([ require('postcss-icss-selectors')(options) ])

See PostCSS docs for examples for your environment.

Options

mode

local by default or global

In local mode

 .foo { ... } /* => */ .file__foo---h63h { ... }

.foo .bar { ... } /* => */ .file__foo----h63h .file__bar----h63h { ... }

/* Shorthand global selector */

:global .foo .bar { ... } /* => */ .foo .bar { ... }

.foo :global .bar { ... } /* => */ .file__foo----h63h .bar { ... }

/* Targeted global selector */

:global(.foo) .bar { ... } /* => */ .foo .file__bar----h63h { ... }

.foo:global(.bar) { ... } /* => */ .file__foo----h63h.bar { ... }

.foo :global(.bar) .baz { ... } /* => */ .file__foo----h63h .bar .file__baz----h63h { ... }

.foo:global(.bar) .baz { ... } /* => */ .file__foo----h63h.bar .file__baz----h63h { ... }

In global mode

 .foo { ... } /* => */ .foo { ... }

.foo .bar { ... } /* => */ .foo .bar { ... }

/* Shorthand local selector */

:local .foo :global .bar { ... } /* => */ .file__foo----h63h .bar { ... }

.foo :local .bar { ... } /* => */ .foo .file__foo----h63h { ... }

/* Targeted local selector */

:local(.foo) .bar { ... } /* => */ .file__foo----h63h .bar { ... }

.foo:local(.bar) { ... } /* => */ .foo.file__bar----h63h { ... }

generateScopeName(localName, filepath, css)

Converts every new local name in #id or .class defintion to global alias.
By default returns [name]__[local]---[hash:base64:5].

Messages

postcss-icss-selectors passes result.messages for each local-scoped class or id

{
  plugin: 'postcss-icss-selectors',
  type: 'icss-scoped',
  name: string, // local-scoped identifier
  value: string // generated global identifier
}

License

MIT © Mark Dalgleish and Bogdan Chadkin, 2015

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin