UI for Zipcoin Blue

WebWorkerChunkTemplatePlugin.js 925B

123456789101112131415161718192021222324252627282930
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ConcatSource = require("webpack-sources").ConcatSource;
  7. const Template = require("../Template");
  8. class WebWorkerChunkTemplatePlugin {
  9. apply(chunkTemplate) {
  10. chunkTemplate.plugin("render", function(modules, chunk) {
  11. const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
  12. const source = new ConcatSource();
  13. source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`);
  14. source.add(modules);
  15. source.add(")");
  16. return source;
  17. });
  18. chunkTemplate.plugin("hash", function(hash) {
  19. hash.update("webworker");
  20. hash.update("3");
  21. hash.update(`${this.outputOptions.chunkCallbackName}`);
  22. hash.update(`${this.outputOptions.library}`);
  23. });
  24. }
  25. }
  26. module.exports = WebWorkerChunkTemplatePlugin;