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
To use this tool we require [Node.js v0.12.x](https://github.com/nodejs/node) (or higher).
24
18
25
19
## Installation
26
20
@@ -30,28 +24,45 @@ $ npm i css-modules-require-hook
30
24
31
25
## Usage
32
26
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.
34
28
35
-
### Development mode
29
+
The first one allows you to pass options manually after module was required. Example:
36
30
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:
Still you can use `devMode` option (see below) to override behavior which is imposed by environment variable.
38
+
// const styles = require('./icon.css');
39
+
```
44
40
45
-
### Basic example
41
+
The second one allows you to move options to the separate file `cmrh.conf.js`. Config file should be located in the same directory where executor is or in its ancestor directories. In that case hook will be attached right after the `css-modules-require-hook/preset` module will be required. Example:
46
42
47
-
Basically to attach the require hook you need to require this module. If you need to adjust it see the tuning section below.
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
62
+
```
63
+
64
+
Still you can use `devMode` option (see below) to override behavior which is imposed by environment variable.
65
+
55
66
### Adding custom PostCSS plugins
56
67
57
68
```javascript
@@ -166,6 +177,10 @@ hook({
166
177
167
178
Attach the require hook to additional file extensions (for example `['.scss']`).
168
179
180
+
### `ignore` function|regex|string
181
+
182
+
Provides possibility to exclude particular files from processing. Supports glob and regular expressions syntax. Also you may provide custom function.
183
+
169
184
### `rootDir` string
170
185
171
186
Provides absolute path to the project directory. Providing this will result in better generated class names. 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.
@@ -213,6 +228,7 @@ Short alias for the [postcss-modules-local-by-default](https://github.com/css-mo
213
228
214
229
[debug](https://www.npmjs.com/package/debug) package is used for debugging. So to turn it on simply specify the **DEBUG** environment variable:
215
230
-`DEBUG=css-modules:fetch`— to see resolved paths to the files.
231
+
-`DEBUG=css-modules:preset`— to see whether config was found or not.
216
232
-`DEBUG=css-modules:setup`— to see the new options list.
0 commit comments