You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
690 B

4 years ago
  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");
  7. class NodeChunkTemplatePlugin {
  8. apply(chunkTemplate) {
  9. chunkTemplate.hooks.render.tap(
  10. "NodeChunkTemplatePlugin",
  11. (modules, chunk) => {
  12. const source = new ConcatSource();
  13. source.add(
  14. `exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `
  15. );
  16. source.add(modules);
  17. source.add(";");
  18. return source;
  19. }
  20. );
  21. chunkTemplate.hooks.hash.tap("NodeChunkTemplatePlugin", hash => {
  22. hash.update("node");
  23. hash.update("3");
  24. });
  25. }
  26. }
  27. module.exports = NodeChunkTemplatePlugin;