a zip code crypto-currency system good for red ONLY

EntryOptionPlugin.js 984B

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