Skip to content

Commit 59b5b85

Browse files
authored
docs(config): clarify resolve.plugin usage (#7769)
Added Mazen050 to the list of contributors and updated the resolve.plugins section to clarify plugin types and usage.
1 parent 04efa48 commit 59b5b85

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/content/configuration/resolve.mdx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ contributors:
1919
- jamesgeorge007
2020
- snitin315
2121
- sapenlei
22+
- Mazen050
2223
---
2324

2425
These options change how modules are resolved. Webpack provides reasonable defaults, but it is possible to change the resolving in detail. Have a look at [Module Resolution](/concepts/module-resolution) for more explanation of how the resolver works.
@@ -645,17 +646,36 @@ module.exports = {
645646

646647
### resolve.plugins
647648

648-
[`[Plugin]`](/plugins/)
649+
[`[Plugin | Function]`](/plugins/)
649650

650-
A list of additional resolve plugins which should be applied. It allows plugins such as [`DirectoryNamedWebpackPlugin`](https://www.npmjs.com/package/directory-named-webpack-plugin).
651+
A list of additional resolve plugins which should be applied.
652+
653+
Each entry can be either:
654+
655+
- A plugin object with an `apply(resolver)` method
656+
- Or a function plugin, which will be called with the resolver as both `this` and the first argument
657+
658+
It allows plugins such as [`DirectoryNamedWebpackPlugin`](https://www.npmjs.com/package/directory-named-webpack-plugin).
651659

652660
**webpack.config.js**
653661

654662
```js
655663
module.exports = {
656664
// ...
657665
resolve: {
658-
plugins: [new DirectoryNamedWebpackPlugin()],
666+
plugins: [
667+
// Object-style plugin
668+
{
669+
apply(resolver) {
670+
// custom logic
671+
},
672+
},
673+
674+
// Function-style plugin
675+
function (resolver) {
676+
// `this` is also the resolver
677+
},
678+
],
659679
},
660680
};
661681
```

0 commit comments

Comments
 (0)