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.

JsonModulesPlugin.js 698B

123456789101112131415161718192021222324252627282930
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const JsonParser = require("./JsonParser");
  7. const JsonGenerator = require("./JsonGenerator");
  8. class JsonModulesPlugin {
  9. apply(compiler) {
  10. compiler.hooks.compilation.tap(
  11. "JsonModulesPlugin",
  12. (compilation, { normalModuleFactory }) => {
  13. normalModuleFactory.hooks.createParser
  14. .for("json")
  15. .tap("JsonModulesPlugin", () => {
  16. return new JsonParser();
  17. });
  18. normalModuleFactory.hooks.createGenerator
  19. .for("json")
  20. .tap("JsonModulesPlugin", () => {
  21. return new JsonGenerator();
  22. });
  23. }
  24. );
  25. }
  26. }
  27. module.exports = JsonModulesPlugin;