react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

Added support for configuring a className prefix #310

Closed sthzg closed 7 years ago

sthzg commented 7 years ago

This feature allows users to put a cssClsPrefix property into their .yo-rc.json. If configured, the component generator will add this string as a prefix to className attributes.

Example:

// .yo-rc.json
{
  "generator-react-webpack": {
    "appName": "v4-latest-install",
    "style": "css",
    "cssmodules": false,
    "cssClsPrefix": "myapp",
    "postcss": false,
    "generatedWithVersion": 4
  }
}

Components generated will now prepend the myapp prefix on their class names, e.g.

$ yo react-webpack:component hello
<div className="myapp-hello-component" />
coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.06%) to 96.078% when pulling 261c6e6f9cbc87520b33597dbeb1599450403fcc on feature/config_clsname_prefix into 01855bd2edafab05586d4c5f5d64ebcdc81687c9 on master.