Skip to content

Commit 9c9d18e

Browse files
committed
added information about processorOpts
1 parent 2a6f905 commit 9c9d18e

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

Diff for: README.md

+31-20
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,23 @@ hook({
120120
});
121121
```
122122

123-
### `append` array
123+
### `devMode` boolean
124124

125-
Appends custom plugins to the end of the PostCSS pipeline. Since the `require` function is synchronous, you should provide synchronous plugins only.
125+
Helps you to invalidate cache of all `require` calls. Usually used for the development purpose. Also overrides behavior, imposed by `NODE_ENV` environment variable. For example:
126126

127-
### `prepend` array
127+
```javascript
128+
hook({
129+
devMode: false,
130+
});
131+
```
128132

129-
Prepends custom plugins to the beginning of the PostCSS pipeline. Since the `require` function is synchronous, you should provide synchronous plugins only.
133+
### `extensions` array
130134

131-
### `use` array
135+
Attach the require hook to additional file extensions (for example `['.scss']`).
132136

133-
Provides the full list of PostCSS plugins to the pipeline. Providing this cancels `append`, `prepend`, `createImportedName`, `generateScopedName` options. Synchronous plugins only.
137+
### `ignore` function|regex|string
138+
139+
Provides possibility to exclude particular files from processing. Supports glob and regular expressions syntax. Also you may provide custom function.
134140

135141
### `preprocessCss` function
136142

@@ -163,31 +169,31 @@ hook({
163169
});
164170
```
165171

166-
### `devMode` boolean
172+
### `processorOpts` object
167173

168-
Helps you to invalidate cache of all `require` calls. Usually used for the development purpose. Also overrides behavior, imposed by `NODE_ENV` environment variable. For example:
174+
Provides possibility to pass custom options to the [LazyResult instance](https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts). It can be usefull if you want to set the custom parser, for example: [postcss-less](https://github.com/gilt/postcss-less).
175+
176+
```javascript
177+
const hook = require('css-modules-require-hook');
178+
const lessParser = require('postcss-less').parse;
169179

170-
```bash
171180
hook({
172-
devMode: false,
181+
extensions: '.less',
182+
processorOpts: {parser: lessParser},
173183
});
174184
```
175185

176-
### `extensions` array
177-
178-
Attach the require hook to additional file extensions (for example `['.scss']`).
179-
180-
### `ignore` function|regex|string
186+
### `append` array
181187

182-
Provides possibility to exclude particular files from processing. Supports glob and regular expressions syntax. Also you may provide custom function.
188+
Appends custom plugins to the end of the PostCSS pipeline. Since the `require` function is synchronous, you should provide synchronous plugins only.
183189

184-
### `rootDir` string
190+
### `prepend` array
185191

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.
192+
Prepends custom plugins to the beginning of the PostCSS pipeline. Since the `require` function is synchronous, you should provide synchronous plugins only.
187193

188-
### `to` string
194+
### `use` array
189195

190-
Provides `to` option to the [LazyResult instance](https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts).
196+
Provides the full list of PostCSS plugins to the pipeline. Providing this cancels `append`, `prepend`, `createImportedName`, `generateScopedName` options. Synchronous plugins only.
191197

192198
### `createImportedName` function
193199

@@ -224,6 +230,11 @@ hook({
224230

225231
Short alias for the [postcss-modules-local-by-default](https://github.com/css-modules/postcss-modules-local-by-default) plugin's option.
226232

233+
### `rootDir` string
234+
235+
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.
236+
237+
227238
## Debugging
228239

229240
[debug](https://www.npmjs.com/package/debug) package is used for debugging. So to turn it on simply specify the **DEBUG** environment variable:

0 commit comments

Comments
 (0)