Projekt

Obecné

Profil

Stáhnout (1.24 KB) 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
const DllEntryDependency = require("./dependencies/DllEntryDependency");
8
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
9
const DllModuleFactory = require("./DllModuleFactory");
10

    
11
class DllEntryPlugin {
12
	constructor(context, entries, name) {
13
		this.context = context;
14
		this.entries = entries;
15
		this.name = name;
16
	}
17

    
18
	apply(compiler) {
19
		compiler.hooks.compilation.tap(
20
			"DllEntryPlugin",
21
			(compilation, { normalModuleFactory }) => {
22
				const dllModuleFactory = new DllModuleFactory();
23
				compilation.dependencyFactories.set(
24
					DllEntryDependency,
25
					dllModuleFactory
26
				);
27
				compilation.dependencyFactories.set(
28
					SingleEntryDependency,
29
					normalModuleFactory
30
				);
31
			}
32
		);
33
		compiler.hooks.make.tapAsync("DllEntryPlugin", (compilation, callback) => {
34
			compilation.addEntry(
35
				this.context,
36
				new DllEntryDependency(
37
					this.entries.map((e, idx) => {
38
						const dep = new SingleEntryDependency(e);
39
						dep.loc = {
40
							name: this.name,
41
							index: idx
42
						};
43
						return dep;
44
					}),
45
					this.name
46
				),
47
				this.name,
48
				callback
49
			);
50
		});
51
	}
52
}
53

    
54
module.exports = DllEntryPlugin;
(32-32/144)