Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.39 KB

File metadata and controls

63 lines (51 loc) · 1.39 KB

react-classname-prefix-loader-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 MyComponent

Output:

class MyComponent extends React.Component {
  render () {
    return <div className='your_prefix-myclass'></div>
  }
}

export default MyComponent

Also works with classnames module!

Installation

$ npm install react-classname-prefix-loader-with-lookup --save-dev 

Usage

module: {
 loaders: [
  {
    test: /\.js$/,
    exclude: /node_modules/,
    use: [{
              loader: 'babel-loader'
           },
           {
              loader: 'react-classname-prefix-loader-with-lookup',
              options:{
                prefix:'prefix-',
                fileName: ['./src/main.css','./src/style.css']
              }
    }]
  },
 ],
},

Recommendation

Credits

Plugin based on