Skip to content

Commit 6c79bf2

Browse files
committed
readme update
1 parent 0049e3f commit 6c79bf2

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

README.md

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,55 @@ $ npm i css-modules-require-hook
2626
require('css-modules-require-hook');
2727
```
2828

29-
## Specifying options
29+
## Available options
30+
31+
Providing additional options allows you to get advanced experience. See the variants below.
32+
33+
```javascript
34+
var hook = require('css-modules-require-hook');
35+
hook({ /* options */ });
36+
```
37+
38+
### `rootDir` option
39+
40+
Aliases are `root`, `d`.
41+
42+
Absolute path to your project's root directory. This is optional but providing it will result in better generated classnames. It can be obligatory, if you run require hook and build tools, like [css-modulesify](https://github.com/css-modules/css-modulesify) from different working directories.
43+
44+
### `use` option
45+
46+
Alias is `u`.
47+
48+
Custom list of plugins. This is optional but helps you to extend list of basic [postcss](https://github.com/postcss/postcss) plugins. Also helps to specify options for particular plugins.
49+
50+
### `createImportedName` option
51+
52+
Alias for the `createImportedName` option from the [postcss-modules-extract-imports](https://github.com/css-modules/postcss-modules-extract-imports) plugin. This is optional. Won't work if you `use` option.
53+
54+
### `generateScopedName` option
55+
56+
Custom function to generate class names. This is optional. Alias for the `generateScopedName` option from the [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope) plugin. Won't work if you `use` option.
57+
58+
### `mode` option
59+
60+
Alias for the `mode` option from the [postcss-modules-local-by-default](https://github.com/css-modules/postcss-modules-local-by-default) plugin. This is optional. Won't work if you `use` option.
61+
62+
## Examples
63+
64+
If you want to add some custom functionality, for example [CSS Next](http://cssnext.io/setup/#as-a-postcss-plugin) plugin, you should provide the `use` option.
3065

3166
```javascript
32-
require('css-modules-require-hook')({
33-
// If you run css-modulesify and require-hook from different directories,
34-
// you have to specify similar root directories
35-
// in order to get the same class names
36-
root: '...', // please, use the absolute path here. It's process.cwd() by default
37-
// Setting this allows you to specify custom PostCSS plugins
38-
// You may use functions or strings, which match to the modules with the same name
39-
use: [] // may use `u` for short
67+
var hook = require('css-modules-require-hook');
68+
69+
hook({
70+
use: [
71+
// adding CSS Next plugin
72+
require('cssnext')(),
73+
74+
// adding basic css-modules plugins
75+
require('postcss-modules-extract-imports'),
76+
require('postcss-modules-local-by-default'),
77+
require('postcss-modules-scope')
78+
]
4079
});
4180
```

0 commit comments

Comments
 (0)