Skip to content

Commit 6c2f378

Browse files
committed
Adding function support to noParse
1 parent 8ad6d27 commit 6c2f378

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/NormalModule.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class NormalModule extends Module {
224224
if(typeof rule === "string") {
225225
return content.indexOf(rule) === 0;
226226
}
227+
228+
if(typeof rule === "function") {
229+
return rule(content);
230+
}
227231
// we assume rule is a regexp
228232
return rule.test(content);
229233
}

schemas/webpackOptionsSchema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@
159159
{
160160
"instanceof": "RegExp"
161161
},
162+
{
163+
"instanceof": "Function"
164+
},
162165
{
163166
"items": {
164167
"type": "string",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
22
module: {
3-
noParse: /not-parsed/
3+
noParse: function(content) {
4+
return /not-parsed/.test(content);
5+
}
46
}
57
};

0 commit comments

Comments
 (0)