main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | /** @typedef {import("./Resolver")} Resolver */
|
---|
9 | /** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
|
---|
10 | /** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
---|
11 |
|
---|
12 | module.exports = class AppendPlugin {
|
---|
13 | /**
|
---|
14 | * @param {string | ResolveStepHook} source source
|
---|
15 | * @param {string} appending appending
|
---|
16 | * @param {string | ResolveStepHook} target target
|
---|
17 | */
|
---|
18 | constructor(source, appending, target) {
|
---|
19 | this.source = source;
|
---|
20 | this.appending = appending;
|
---|
21 | this.target = target;
|
---|
22 | }
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * @param {Resolver} resolver the resolver
|
---|
26 | * @returns {void}
|
---|
27 | */
|
---|
28 | apply(resolver) {
|
---|
29 | const target = resolver.ensureHook(this.target);
|
---|
30 | resolver
|
---|
31 | .getHook(this.source)
|
---|
32 | .tapAsync("AppendPlugin", (request, resolveContext, callback) => {
|
---|
33 | /** @type {ResolveRequest} */
|
---|
34 | const obj = {
|
---|
35 | ...request,
|
---|
36 | path: request.path + this.appending,
|
---|
37 | relativePath:
|
---|
38 | request.relativePath && request.relativePath + this.appending
|
---|
39 | };
|
---|
40 | resolver.doResolve(
|
---|
41 | target,
|
---|
42 | obj,
|
---|
43 | this.appending,
|
---|
44 | resolveContext,
|
---|
45 | callback
|
---|
46 | );
|
---|
47 | });
|
---|
48 | }
|
---|
49 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.