source: trip-planner-front/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1003 bytes
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const basename = require("./getPaths").basename;
9
10/** @typedef {import("./Resolver")} Resolver */
11
12module.exports = class CloneBasenamePlugin {
13 constructor(source, target) {
14 this.source = source;
15 this.target = target;
16 }
17
18 /**
19 * @param {Resolver} resolver the resolver
20 * @returns {void}
21 */
22 apply(resolver) {
23 const target = resolver.ensureHook(this.target);
24 resolver
25 .getHook(this.source)
26 .tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => {
27 const filename = basename(request.path);
28 const filePath = resolver.join(request.path, filename);
29 const obj = {
30 ...request,
31 path: filePath,
32 relativePath:
33 request.relativePath &&
34 resolver.join(request.relativePath, filename)
35 };
36 resolver.doResolve(
37 target,
38 obj,
39 "using path: " + filePath,
40 resolveContext,
41 callback
42 );
43 });
44 }
45};
Note: See TracBrowser for help on using the repository browser.