You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
758 B

4 years ago
  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 AppendPlugin {
  7. constructor(source, appending, target) {
  8. this.source = source;
  9. this.appending = appending;
  10. this.target = target;
  11. }
  12. apply(resolver) {
  13. const target = resolver.ensureHook(this.target);
  14. resolver
  15. .getHook(this.source)
  16. .tapAsync("AppendPlugin", (request, resolveContext, callback) => {
  17. const obj = Object.assign({}, request, {
  18. path: request.path + this.appending,
  19. relativePath:
  20. request.relativePath && request.relativePath + this.appending
  21. });
  22. resolver.doResolve(
  23. target,
  24. obj,
  25. this.appending,
  26. resolveContext,
  27. callback
  28. );
  29. });
  30. }
  31. };