|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -var EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin"); |
6 | | -var SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin"); |
| 5 | +"use strict"; |
7 | 6 |
|
8 | | -function EvalSourceMapDevToolPlugin(options) { |
9 | | - if(arguments.length > 1) |
10 | | - throw new Error("EvalSourceMapDevToolPlugin only takes one argument (pass an options object)"); |
11 | | - if(typeof options === "string") { |
12 | | - options = { |
13 | | - append: options |
14 | | - }; |
| 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("EvalSourceMapDevToolPlugin only takes one argument (pass an options object)"); |
| 14 | + if(typeof options === "string") { |
| 15 | + options = { |
| 16 | + append: options |
| 17 | + }; |
| 18 | + } |
| 19 | + if(!options) options = {}; |
| 20 | + this.options = options; |
| 21 | + } |
| 22 | + |
| 23 | + apply(compiler) { |
| 24 | + let options = this.options; |
| 25 | + compiler.plugin("compilation", (compilation) => { |
| 26 | + new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation); |
| 27 | + compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options)); |
| 28 | + }); |
15 | 29 | } |
16 | | - if(!options) options = {}; |
17 | | - this.options = options; |
18 | 30 | } |
| 31 | + |
19 | 32 | module.exports = EvalSourceMapDevToolPlugin; |
20 | | -EvalSourceMapDevToolPlugin.prototype.apply = function(compiler) { |
21 | | - var options = this.options; |
22 | | - compiler.plugin("compilation", function(compilation) { |
23 | | - new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation); |
24 | | - compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options)); |
25 | | - }); |
26 | | -}; |
|
0 commit comments