|
1 | 1 | /* |
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | | -*/ |
5 | | -var SingleEntryPlugin = require("./SingleEntryPlugin"); |
6 | | -var MultiEntryPlugin = require("./MultiEntryPlugin"); |
| 4 | + */ |
| 5 | +"use strict"; |
7 | 6 |
|
8 | | -function EntryOptionPlugin() {} |
9 | | -module.exports = EntryOptionPlugin; |
| 7 | +const SingleEntryPlugin = require("./SingleEntryPlugin"); |
| 8 | +const MultiEntryPlugin = require("./MultiEntryPlugin"); |
10 | 9 |
|
11 | | -EntryOptionPlugin.prototype.apply = function(compiler) { |
12 | | - compiler.plugin("entry-option", function(context, entry) { |
13 | | - function itemToPlugin(item, name) { |
14 | | - if(Array.isArray(item)) |
15 | | - return new MultiEntryPlugin(context, item, name); |
16 | | - else |
17 | | - return new SingleEntryPlugin(context, item, name); |
18 | | - } |
19 | | - if(typeof entry === "string" || Array.isArray(entry)) { |
20 | | - compiler.apply(itemToPlugin(entry, "main")); |
21 | | - } else if(typeof entry === "object") { |
22 | | - Object.keys(entry).forEach(function(name) { |
23 | | - compiler.apply(itemToPlugin(entry[name], name)); |
24 | | - }); |
25 | | - } |
26 | | - return true; |
27 | | - }); |
28 | | -}; |
| 10 | +module.exports = class EntryOptionPlugin { |
| 11 | + apply(compiler) { |
| 12 | + compiler.plugin("entry-option", (context, entry) => { |
| 13 | + function itemToPlugin(item, name) { |
| 14 | + if(Array.isArray(item)) { |
| 15 | + return new MultiEntryPlugin(context, item, name); |
| 16 | + } else { |
| 17 | + return new SingleEntryPlugin(context, item, name); |
| 18 | + } |
| 19 | + } |
| 20 | + if(typeof entry === "string" || Array.isArray(entry)) { |
| 21 | + compiler.apply(itemToPlugin(entry, "main")); |
| 22 | + } else if(typeof entry === "object") { |
| 23 | + Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name))); |
| 24 | + } |
| 25 | + return true; |
| 26 | + }); |
| 27 | + } |
| 28 | +} |
0 commit comments