Skip to content

Commit

Permalink
docs(plugins): add a note for resourceRegExp (#5450)
Browse files Browse the repository at this point in the history
* docs(plugins): add a note for resourceRegExp

* wrap with single quotes
  • Loading branch information
chenxsan committed Sep 15, 2021
1 parent b907689 commit d07fcdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/content/plugins/normal-module-replacement-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ group: webpack
contributors:
- gonzoyumo
- byzyk
- chenxsan
---

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.
Expand All @@ -14,6 +15,8 @@ This can be useful for allowing different behaviour between builds.
new webpack.NormalModuleReplacementPlugin(resourceRegExp, newResource);
```

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'`.

## Basic Example

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

1 comment on commit d07fcdb

@vercel
Copy link

@vercel vercel bot commented on d07fcdb Sep 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.