Webpack plugin to add a prefix to all css selectors classes and ids.
Install postcss-prefix-webpack
on your project directory:
npm install postcss-prefix-webpack --save-dev
Type: string
Default: none
Type: string
Default: none
Type: string
Default: none
String to be used as prefix
Type: array
Default: []
Example of usage with results generated by the plugin.
const PostCSSPrefix = require('postcss-prefix-webpack');
module.exports = {
entry: 'index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new PostCSSPrefix({
input:'./src/style.css',
output: './public/style-prefix.css',
prefixProperties: {
prefix: 'prefix-',
ignore: [/selector-/, '.ignore', '#ignore']
}
})
]
}
#selector-one .example {
/* content */
}
.selector-two .example2 {
/* content */
}
#ignore .ignore {
/* content */
}
#ignore .other {
/* content */
}
#selector-one .prefix-example {
/* content */
}
.selector-two .prefix-example2 {
/* content */
}
#ignore .ignore {
/* content */
}
#ignore .prefix-other {
/* content */
}
- Use it with react-classname-prefix-loader-with-lookup for react className
Plugin based on
- postcss-class-prefix create by thompsongl.
- postcss-prefixer create by Marcelo Ucker.