1.0.0 • Published 6 years ago

react-app-rewire-css-modules-simple v1.0.0

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

react-app-rewire-css-modules-simple npm

Add CSS Module loaders to your create-react-app via react-app-rewired. Simple, without SASS or LESS.

Installation

npm install --save-dev react-app-rewire-css-modules-simple

Usage

Use the following file extensions for any css module styles:

  • *.module.css

Example

In your react-app-rewired configuration:

/* config-overrides.js */

const rewireCssModules = require("react-app-rewire-css-modules-simple");

module.exports = function override(config, env) {
  
  config = rewireCssModules(config, env);
  
  // with loaderOptions
  config = rewireCssModules.withLoaderOptions({
    localIdentName: '[local]___[hash:base64:5]',
  })(config, env);

  return config;
};

In your React application:

/* App.module.css */

.div {
  color: red;
}
// App.js

import React from 'react';
import styles from './App.module.css';

export default ({text}) => (
    <div className={styles.div}>{text}</div>
)