1
|
/*
|
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
Author Tobias Koppers @sokra
|
4
|
*/
|
5
|
"use strict";
|
6
|
|
7
|
module.exports = class FileKindPlugin {
|
8
|
constructor(source, target) {
|
9
|
this.source = source;
|
10
|
this.target = target;
|
11
|
}
|
12
|
|
13
|
apply(resolver) {
|
14
|
const target = resolver.ensureHook(this.target);
|
15
|
resolver.getHook(this.source).tapAsync("FileKindPlugin", (request, resolveContext, callback) => {
|
16
|
if(request.directory) return callback();
|
17
|
const obj = Object.assign({}, request);
|
18
|
delete obj.directory;
|
19
|
resolver.doResolve(target, obj, null, resolveContext, callback);
|
20
|
});
|
21
|
}
|
22
|
};
|