Skip to content

Commit afb5123

Browse files
committed
docs(plugins): add a note for resourceRegExp
1 parent 70d8e08 commit afb5123

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/content/plugins/normal-module-replacement-plugin.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ group: webpack
44
contributors:
55
- gonzoyumo
66
- byzyk
7+
- chenxsan
78
---
89

910
The `NormalModuleReplacementPlugin` allows you to replace resources that match `resourceRegExp` with `newResource`. If `newResource` is relative, it is resolved relative to the previous resource. If `newResource` is a function, it is expected to overwrite the request attribute of the supplied resource.
@@ -14,6 +15,8 @@ This can be useful for allowing different behaviour between builds.
1415
new webpack.NormalModuleReplacementPlugin(resourceRegExp, newResource);
1516
```
1617

18+
Note that the `resourceRegExp` is tested against the request you write in your code, not the resolved resource. For instance, `'./sum'` will be used to test instead of `./sum.js` when you have code `import sum from './sum'`.
19+
1720
## Basic Example
1821

1922
Replace a specific module when building for a [development environment](/guides/production).

0 commit comments

Comments
 (0)