postcss-selector-rename
v3.0.1
Published
A PostCSS plugin to rename css selector
Downloads
1,149
Maintainers
Readme
[email protected]
A PostCSS plugin to rename css selector.
- required postcss >= 8.0
.foo {
}
div {
}
.rename-foo {
}
rename-div {
}
Options
default options
{
test: (name) => true,
selector: {
classes: true,
ids: false,
tags: true,
},
rename: (name, type) => name
}
test?: (name: string) => boolean
|RegExp
only rename when return trueselector?: Partial<Record<'classes' | 'tags' | 'ids', boolean>>
walk selector typerename: (name: string, type: 'classes' | 'tags' | 'ids') => string
return new selector name
Usage
Step 1: Install plugin:
npm install --save-dev postcss postcss-selector-rename
Step 2: Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
module.exports = {
plugins: [
+ [require('postcss-selector-rename'), Options],
require('autoprefixer')
]
}