webpack/lib/node/NodeTemplatePlugin.js

32 lines
880 B
JavaScript
Raw Normal View History

2013-01-31 01:49:25 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const NodeChunkTemplatePlugin = require("./NodeChunkTemplatePlugin");
const NodeHotUpdateChunkTemplatePlugin = require("./NodeHotUpdateChunkTemplatePlugin");
2018-07-30 23:08:51 +08:00
const NodeMainTemplatePlugin = require("./NodeMainTemplatePlugin");
class NodeTemplatePlugin {
constructor(options) {
options = options || {};
this.asyncChunkLoading = options.asyncChunkLoading;
}
apply(compiler) {
2018-02-25 09:00:20 +08:00
compiler.hooks.thisCompilation.tap("NodeTemplatePlugin", compilation => {
new NodeMainTemplatePlugin(this.asyncChunkLoading).apply(
compilation.mainTemplate
);
new NodeChunkTemplatePlugin().apply(compilation.chunkTemplate);
2018-02-25 09:00:20 +08:00
new NodeHotUpdateChunkTemplatePlugin().apply(
compilation.hotUpdateChunkTemplate
);
});
}
2013-01-31 01:49:25 +08:00
}
2013-03-01 16:44:58 +08:00
module.exports = NodeTemplatePlugin;