Skip to content

Commit 86a0a08

Browse files
committed
readme update
1 parent 1afd7af commit 86a0a08

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ Compiling in runtime, [universal](https://medium.com/@mjackson/universal-javascr
1414

1515
## Requirements
1616

17-
To use this tool we require [Node.js v0.12.x](https://github.com/nodejs/node) (or higher) and several modules to be installed.
18-
19-
- [postcss](https://github.com/postcss/postcss) version 5 or higher
20-
- [postcss-modules-values](https://github.com/css-modules/postcss-modules-values)
21-
- [postcss-modules-extract-imports](https://github.com/css-modules/postcss-modules-extract-imports)
22-
- [postcss-modules-local-by-default](https://github.com/css-modules/postcss-modules-local-by-default)
23-
- [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope)
17+
To use this tool we require [Node.js v0.12.x](https://github.com/nodejs/node) (or higher).
2418

2519
## Installation
2620

@@ -30,28 +24,45 @@ $ npm i css-modules-require-hook
3024

3125
## Usage
3226

33-
In this section I've tried to cover the common cases of usage.
27+
Now, there are two ways to attach hook: manually or using preset file.
3428

35-
### Development mode
29+
The first one allows you to pass options manually after module was required, to make it work. Example:
3630

37-
Usually, Node.js caches all the `require` calls by default. In order to invalidate cache for the purpose of development you should set the environment variable `NODE_ENV` to `development`. For example:
31+
```javascript
32+
const hook = require('css-modules-require-hook');
3833

39-
```bash
40-
$ NODE_ENV=development node server.js
41-
```
34+
hook({
35+
generateScopedName: '[name]__[local]___[hash:base64:5]',
36+
});
4237

43-
Still you can use `devMode` option (see below) to override behavior which is imposed by environment variable.
38+
// const styles = require('./icon.css');
39+
```
4440

45-
### Basic example
41+
The second one allows you to move options to separated file `cmrh.conf.js`, which should be located in your working directory (`process.cwd()`) or in its ancestors. Example:
4642

47-
Basically to attach the require hook you need to require this module. If you need to adjust it see the tuning section below.
43+
```javascript
44+
// cmrh.conf.js
45+
module.exports = {
46+
generateScopedName: '[name]__[local]___[hash:base64:5]',
47+
};
48+
```
4849

4950
```javascript
50-
require('css-modules-require-hook');
51+
require('css-modules-require-hook/preset');
52+
53+
// const styles = require('./icon.css');
54+
```
55+
56+
### Development mode
5157

52-
// var styles = require('./icon.css');
58+
Usually, Node.js caches all the `require` calls by default. In order to invalidate cache for the purpose of development you should set the environment variable `NODE_ENV` to `development`. For example:
59+
60+
```bash
61+
$ NODE_ENV=development node server.js
5362
```
5463

64+
Still you can use `devMode` option (see below) to override behavior which is imposed by environment variable.
65+
5566
### Adding custom PostCSS plugins
5667

5768
```javascript

0 commit comments

Comments
 (0)