選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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. };