1
|
/*
|
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
Author Tobias Koppers @sokra
|
4
|
*/
|
5
|
"use strict";
|
6
|
|
7
|
const EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin");
|
8
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
9
|
|
10
|
class EvalSourceMapDevToolPlugin {
|
11
|
constructor(options) {
|
12
|
if (arguments.length > 1) {
|
13
|
throw new Error(
|
14
|
"EvalSourceMapDevToolPlugin only takes one argument (pass an options object)"
|
15
|
);
|
16
|
}
|
17
|
if (typeof options === "string") {
|
18
|
options = {
|
19
|
append: options
|
20
|
};
|
21
|
}
|
22
|
if (!options) options = {};
|
23
|
this.options = options;
|
24
|
}
|
25
|
|
26
|
apply(compiler) {
|
27
|
const options = this.options;
|
28
|
compiler.hooks.compilation.tap(
|
29
|
"EvalSourceMapDevToolPlugin",
|
30
|
compilation => {
|
31
|
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
32
|
new EvalSourceMapDevToolModuleTemplatePlugin(
|
33
|
compilation,
|
34
|
options
|
35
|
).apply(compilation.moduleTemplates.javascript);
|
36
|
}
|
37
|
);
|
38
|
}
|
39
|
}
|
40
|
|
41
|
module.exports = EvalSourceMapDevToolPlugin;
|