LogInfoPlugin.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 LogInfoPlugin {
  7. constructor(source) {
  8. this.source = source;
  9. }
  10. apply(resolver) {
  11. const source = this.source;
  12. resolver
  13. .getHook(this.source)
  14. .tapAsync("LogInfoPlugin", (request, resolveContext, callback) => {
  15. if (!resolveContext.log) return callback();
  16. const log = resolveContext.log;
  17. const prefix = "[" + source + "] ";
  18. if (request.path)
  19. log(prefix + "Resolving in directory: " + request.path);
  20. if (request.request)
  21. log(prefix + "Resolving request: " + request.request);
  22. if (request.module) log(prefix + "Request is an module request.");
  23. if (request.directory) log(prefix + "Request is a directory request.");
  24. if (request.query)
  25. log(prefix + "Resolving request query: " + request.query);
  26. if (request.descriptionFilePath)
  27. log(
  28. prefix + "Has description data from " + request.descriptionFilePath
  29. );
  30. if (request.relativePath)
  31. log(
  32. prefix +
  33. "Relative path from description file is: " +
  34. request.relativePath
  35. );
  36. callback();
  37. });
  38. }
  39. };