Code Monkey home page Code Monkey logo

react-classnameprefix-loader's Introduction

react-classnamePrefix-loader

A Webpack loader that prefixes classes with custom prefix in React components.

This loader is an Improvement over react-classname-prefix-loader

install

via npm
npm install react-cnpl --save-dev
via yarn
yarn add react-cnpl --dev

Very simple configuration module loader example:

...

module: {
    loaders: [{
      ...
    }, {
        test: /\.jsx$/,
        exclude: [/node_modules/],
        loader: "react-cnpl",
        query: {
            prefixname:'<prefixname>--'
        }
    }]
}

...
class MyComponent extends React.Component {
  render () {
    return (
      <div className="block">
        <div className="block inner">
          <h1 className="block inner title_name_">Title</h1>
        </div>
      </div>
    )
  }
}
output will be
<div className="prefixname--block">
  <div className="prefixname--block prefixname--inner">
    <h1 className="prefixname--block prefixname--inner prefixname--title_name_">Title</h1>
  </div>
</div>

ignore : Object

ignoring classNames and elements

...

module: {
    loaders: [{
      ...
    }, {
        test: /\.jsx$/,
        exclude: [/node_modules/],
        loader: "react-cnpl",
        query: {
            prefixname:'<prefixname>--',
            ignore:{
              // ignoring elements using array
              elements:['div','pre','i'],
              // ignoring classname using array
              className:['x','y','z']
            }
        }
    }]
}

...

Recommendation

Use it with postcss-class-prefix for css files

react-classnameprefix-loader's People

Contributors

vaheqelyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-classnameprefix-loader's Issues

Does not work

Just a heads up for anyone that is looking for a similar solution and ends up on this package.

I don't think this loader works. It's possible that it only doesn't work with modules that use classnames but I haven't had time to put together a simplified reproduction example to confirm that yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.