a zip code crypto-currency system good for red ONLY

MultiEntryPlugin.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const MultiEntryDependency = require("./dependencies/MultiEntryDependency");
  7. const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
  8. const MultiModuleFactory = require("./MultiModuleFactory");
  9. module.exports = class MultiEntryPlugin {
  10. constructor(context, entries, name) {
  11. this.context = context;
  12. this.entries = entries;
  13. this.name = name;
  14. }
  15. apply(compiler) {
  16. compiler.plugin("compilation", (compilation, params) => {
  17. const multiModuleFactory = new MultiModuleFactory();
  18. const normalModuleFactory = params.normalModuleFactory;
  19. compilation.dependencyFactories.set(MultiEntryDependency, multiModuleFactory);
  20. compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
  21. });
  22. compiler.plugin("make", (compilation, callback) => {
  23. const dep = MultiEntryPlugin.createDependency(this.entries, this.name);
  24. compilation.addEntry(this.context, dep, this.name, callback);
  25. });
  26. }
  27. static createDependency(entries, name) {
  28. return new MultiEntryDependency(entries.map((e, idx) => {
  29. const dep = new SingleEntryDependency(e);
  30. dep.loc = name + ":" + (100000 + idx);
  31. return dep;
  32. }), name);
  33. }
  34. };