Package Exports
- react-classname-prefix-loader-with-lookup
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-classname-prefix-loader-with-lookup) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-classname-prefix-with-lookup
A Webpack loader that prefixes classes with custom prefix in React components. You can use lookup css files and if class presents then only it will update with prefix.
MyComponent.js
class MyComponent extends React.Component {
render () {
return <div className='myclass'></div>
}
}
export default MyComponentOutput:
class MyComponent extends React.Component {
render () {
return <div className='your_prefix-myclass'></div>
}
}
export default MyComponentAlso works with classnames module!
Installation
$ npm install react-classname-prefix-with-lookup --save-dev Usage
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader'
},
{
loader: path.resolve('react-classnames-prefix.js'),
options:{
prefix:'prefix-',
fileName: ['./src/main.css','./src/style.css']
}
}]
},
],
},Recommendation
- Use it with postcss-prefix-webpack for css files
Credits
Plugin based on
- react-classname-prefix-loader create by vezetvsem.