react-webpack-generators / react-webpack-template

Simple react webpack template
MIT License
82 stars 44 forks source link

Configuring Webpack loaders for CSSModules + Preprocessor #32

Closed sthzg closed 8 years ago

sthzg commented 8 years ago

Moved from https://github.com/newtriks/generator-react-webpack/issues/248

After installing the 4.x generator with CSSModules + Preprocessor (e.g. LESS) and creating a new component the component template creates

- Foobar.js
- foobar.cssmodule.less
import styles from './foobar.cssmodule.less';
// ...
<div className="foobar-component" styleName="foobar-component" />

Rendering will fail with an exception of css module is undefined, because the loaders in cfg/base are configured for for the *.less files only and miss a test against *.cssmodule.less and a loader that is adapted for cssmodules ('css?modules&importLoaders=1&localIdentName=[name]-[local]-[hash:base64:5]').

weblogixx commented 8 years ago

Just added your pr, thank you!