FunctionModulePlugin.js 706B

12345678910111213141516171819202122232425
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const FunctionModuleTemplatePlugin = require("./FunctionModuleTemplatePlugin");
  7. const RequestShortener = require("./RequestShortener");
  8. class FunctionModulePlugin {
  9. constructor(options, requestShortener) {
  10. this.options = options;
  11. this.requestShortener = requestShortener;
  12. }
  13. apply(compiler) {
  14. compiler.plugin("compilation", (compilation) => {
  15. compilation.moduleTemplate.requestShortener = this.requestShortener || new RequestShortener(compiler.context);
  16. compilation.moduleTemplate.apply(new FunctionModuleTemplatePlugin());
  17. });
  18. }
  19. }
  20. module.exports = FunctionModulePlugin;