FileKindPlugin.js 622 B

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