Projekt

Obecné

Profil

Stáhnout (798 Bajtů) Statistiky
| Větev: | Revize:
1
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
"use strict";
6

    
7
module.exports = class UseFilePlugin {
8
	constructor(source, filename, target) {
9
		this.source = source;
10
		this.filename = filename;
11
		this.target = target;
12
	}
13

    
14
	apply(resolver) {
15
		const target = resolver.ensureHook(this.target);
16
		resolver.getHook(this.source).tapAsync("UseFilePlugin", (request, resolveContext, callback) => {
17
			const filePath = resolver.join(request.path, this.filename);
18
			const obj = Object.assign({}, request, {
19
				path: filePath,
20
				relativePath: request.relativePath && resolver.join(request.relativePath, this.filename)
21
			});
22
			resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
23
		});
24
	}
25
};
(31-31/39)