You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-9Lines changed: 48 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -26,16 +26,55 @@ $ npm i css-modules-require-hook
26
26
require('css-modules-require-hook');
27
27
```
28
28
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 custom functionality, for example [CSS Next](http://cssnext.io/setup/#as-a-postcss-plugin) plugin, you should provide the `use` option.
30
65
31
66
```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
0 commit comments