-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (34 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @file 忽略部分文件
*/
const loaderUtils = require('loader-utils');
const template = '';
module.exports = function (source) {
const options = loaderUtils.getOptions(this) || {};
const root = (this.options || this._compiler.context || {}).context || {};
const resourcePath = this.resourcePath.replace(root, '');
// console.log('options:', options);
// console.log('root:', root);
if (options.test) {
for(let i = 0; i < options.test.length; i++) {
let path = options.test[i];
if (typeof path === 'string') {
if (resourcePath.indexOf(path) >= 0) {
console.log('ignore:', resourcePath);
return options.template || template;
}
}
else if (path instanceof RegExp) {
if (path.test(resourcePath)) {
console.log('ignore:', resourcePath);
return options.template || template;
}
}
}
}
else {
console.log('ignore:', resourcePath);
return options.template || template;
}
return source;
};