@@ -9,7 +9,7 @@ $ npm install --save-dev string-replace-loader
99```
1010
1111With 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.
1313
1414## Usage:
1515
@@ -42,13 +42,33 @@ module.exports = {
4242
4343### RegEx replacement:
4444
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
4850and this means that you should escape RegEx special characters in ` search ` if you want it to be replaced as a string.
4951
5052In your ` webpack.config.js ` :
5153
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
5272``` javascript
5373module .exports = {
5474 // ...
@@ -117,7 +137,7 @@ module.exports = {
117137 ]
118138 }
119139}
120- ```
140+ ```
121141
122142### Strict mode replacement:
123143
0 commit comments