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