Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CloneBasenamePlugin.js 858B

123456789101112131415161718192021222324252627
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const basename = require("./getPaths").basename;
  7. module.exports = class CloneBasenamePlugin {
  8. constructor(source, target) {
  9. this.source = source;
  10. this.target = target;
  11. }
  12. apply(resolver) {
  13. const target = resolver.ensureHook(this.target);
  14. resolver.getHook(this.source).tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => {
  15. const filename = basename(request.path);
  16. const filePath = resolver.join(request.path, filename);
  17. const obj = Object.assign({}, request, {
  18. path: filePath,
  19. relativePath: request.relativePath && resolver.join(request.relativePath, filename)
  20. });
  21. resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
  22. });
  23. }
  24. };