@@ -9,7 +9,7 @@ $ npm install --save-dev string-replace-loader
9
9
```
10
10
11
11
With release of 2.0.0 the loader is expected to be used in Node v4+ environment.
12
- Support for Node v3 and lower was dropped, but you can install and use the loader version of 1.3.0 in older environments.
12
+ Support for Node v3 and lower was dropped, but you can install and use the loader version of 1.3.0 in older environments.
13
13
14
14
## Usage:
15
15
@@ -42,13 +42,33 @@ module.exports = {
42
42
43
43
### RegEx replacement:
44
44
45
- To achieve regular expression replacement you should specify the ` flags ` option
46
- (as an empty string if you do not want any flags). In this case, ` search ` and ` flags ` are being
47
- passed to the [ RegExp] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp ) constructor
45
+ To achieve regular expression replacement you should either specify the ` search ` option as
46
+ [ RegExp] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp ) instance,
47
+ either specify it as string and add the ` flags ` option (as an empty string if you do not want any flags).
48
+ In the latter case, ` search ` and ` flags ` are being passed to the
49
+ [ RegExp] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp ) constructor
48
50
and this means that you should escape RegEx special characters in ` search ` if you want it to be replaced as a string.
49
51
50
52
In your ` webpack.config.js ` :
51
53
54
+ ``` javascript
55
+ module .exports = {
56
+ // ...
57
+ module: {
58
+ rules: [
59
+ {
60
+ test: / fileInWhichJQueryIsUndefined\. js$ / ,
61
+ loader: ' string-replace-loader' ,
62
+ options: {
63
+ search: / \$ / i ,
64
+ replace: ' window.jQuery'
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ ```
71
+ or
52
72
``` javascript
53
73
module .exports = {
54
74
// ...
@@ -117,7 +137,7 @@ module.exports = {
117
137
]
118
138
}
119
139
}
120
- ```
140
+ ```
121
141
122
142
### Strict mode replacement:
123
143
0 commit comments