webpack/lib/node/NodeTemplatePlugin.js

33 lines
806 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 CommonJsChunkFormatPlugin = require("../javascript/CommonJsChunkFormatPlugin");
const CommonJsChunkLoadingPlugin = require("./CommonJsChunkLoadingPlugin");
2018-11-09 05:59:19 +08:00
/** @typedef {import("../Compiler")} Compiler */
class NodeTemplatePlugin {
constructor(options) {
this._options = options || {};
}
2018-11-09 05:59:19 +08:00
/**
2020-04-23 16:48:36 +08:00
* Apply the plugin
2018-11-09 05:59:19 +08:00
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.options.output.chunkLoading = this._options.asyncChunkLoading
? "async-node"
: "require";
new CommonJsChunkFormatPlugin().apply(compiler);
new CommonJsChunkLoadingPlugin(this._options).apply(compiler);
}
2013-01-31 01:49:25 +08:00
}
2013-03-01 16:44:58 +08:00
module.exports = NodeTemplatePlugin;