You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -25,16 +25,19 @@ new webpack.ContextReplacementPlugin(
25
25
26
26
If the resource (directory) matches `resourceRegExp`, the plugin replaces the default resource, recursive flag or generated regular expression with `newContentResource`, `newContentRecursive` or `newContextRegExp` respectively. If `newContentResource` is relative, it is resolved relative to the previous resource.
The `moment/locale` context is restricted to files matching `/de|fr|hu/`. Thus only those locales are included (see also [this GitHub issue](https://github.com/moment/moment/issues/2373)).
37
+
The `moment/locale` context is restricted to files matching `/de|fr|hu/`. Thus only those locales are included (see [this issue](https://github.com/moment/moment/issues/2373) for more information).
35
38
36
39
37
-
## `newContentCallback`
40
+
## Content Callback
38
41
39
42
```javascript
40
43
newwebpack.ContextReplacementPlugin(
@@ -43,22 +46,25 @@ new webpack.ContextReplacementPlugin(
43
46
)
44
47
```
45
48
46
-
The function `newContentCallback` is given a [`data` object of the `ContextModuleFactory`](/api/plugins/module-factories/) and it is expected to overwrite the `request` attribute of the supplied object.
49
+
The `newContentCallback`function is given a [`data` object of the `ContextModuleFactory`](/api/plugins/module-factories/) and is expected to overwrite the `request` attribute of the supplied object.
47
50
48
-
**Example**
51
+
Using this callback we can dynamically redirect requests to a new location:
The `newContentResource` and `newContentCreateContextMap` parameters are also available:
62
68
63
69
```javascript
64
70
newwebpack.ContextReplacementPlugin(
@@ -68,12 +74,11 @@ new webpack.ContextReplacementPlugin(
68
74
)
69
75
```
70
76
71
-
**Example**
77
+
These two parameters can be used together to redirect requests in a more targeted way. The `newContentCreateContextMap` allows you to map runtime requests to compile requests in the form of an object:
0 commit comments