Skip to content

Commit cb25c9b

Browse files
bewEugeneHlushko
authored andcommitted
Add documentation for Rule.use as a function (#2694)
1 parent be32f4a commit cb25c9b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/content/configuration/module.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,25 @@ module.exports = {
308308

309309
## `Rule.use`
310310

311-
A list of [UseEntries](#useentry) which are applied to modules. Each entry specifies a loader to be used.
311+
`[UseEntry] | function`
312+
313+
`Rule.use` can be an array of [UseEntry](#useentry) which are applied to modules. Each entry specifies a loader to be used.
312314

313315
Passing a string (i.e. `use: [ 'style-loader' ]`) is a shortcut to the loader property (i.e. `use: [ { loader: 'style-loader '} ]`).
314316

315317
Loaders can be chained by passing multiple loaders, which will be applied from right to left (last to first configured).
316318

319+
`Rule.use` can be a function which receives the object argument describing the module being loaded, and must return an array of `UseEntry`.
320+
321+
The object parameter has the following fields:
322+
323+
- `compiler`: The current webpack compiler (can be undefined)
324+
- `issuer`: The path to the module that is importing the module being loaded
325+
- `realResource`: Always the path to the module being loaded
326+
- `resource`: The path to the module being loaded, it is usually equal to `realResource` except when the resource name is overwritten via `!=!` in request string
327+
328+
The same shortcut as an array can be used for the return value (i.e. `use: [ 'style-loader' ]`).
329+
317330
__webpack.config.js__
318331

319332
```javascript

0 commit comments

Comments
 (0)