webpack/lib/node/NodeTemplatePlugin.js

22 lines
871 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
*/
var NodeMainTemplatePlugin = require("./NodeMainTemplatePlugin");
var NodeChunkTemplatePlugin = require("./NodeChunkTemplatePlugin");
var NodeHotUpdateChunkTemplate = require("./NodeHotUpdateChunkTemplate");
2013-01-31 01:49:25 +08:00
function NodeTemplatePlugin(options, asyncChunkLoading) {
2013-01-31 01:49:25 +08:00
this.options = options;
this.asyncChunkLoading = asyncChunkLoading;
2013-01-31 01:49:25 +08:00
}
2013-03-01 16:44:58 +08:00
module.exports = NodeTemplatePlugin;
NodeTemplatePlugin.prototype.apply = function(compiler) {
2013-01-31 01:49:25 +08:00
var options = this.options;
compiler.plugin("this-compilation", function(compilation) {
compilation.mainTemplate.apply(new NodeMainTemplatePlugin(this.asyncChunkLoading));
compilation.chunkTemplate.apply(new NodeChunkTemplatePlugin());
}.bind(this));
compiler.hotUpdateChunkTemplate = new NodeHotUpdateChunkTemplate(options);
2013-03-01 16:44:58 +08:00
};