WebWorkerTemplatePlugin.js 742 B

12345678910111213141516171819202122232425
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ArrayPushCallbackChunkFormatPlugin = require("../javascript/ArrayPushCallbackChunkFormatPlugin");
  7. const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin");
  8. /** @typedef {import("../Compiler")} Compiler */
  9. class WebWorkerTemplatePlugin {
  10. /**
  11. * Apply the plugin
  12. * @param {Compiler} compiler the compiler instance
  13. * @returns {void}
  14. */
  15. apply(compiler) {
  16. compiler.options.output.chunkLoading = "import-scripts";
  17. new ArrayPushCallbackChunkFormatPlugin().apply(compiler);
  18. new EnableChunkLoadingPlugin("import-scripts").apply(compiler);
  19. }
  20. }
  21. module.exports = WebWorkerTemplatePlugin;