2013-01-31 01:49:25 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
|
2017-01-08 00:06:08 +08:00
|
|
|
"use strict";
|
|
|
|
|
2020-08-25 16:30:56 +08:00
|
|
|
const CommonJsChunkFormatPlugin = require("../javascript/CommonJsChunkFormatPlugin");
|
2020-08-25 19:20:29 +08:00
|
|
|
const CommonJsChunkLoadingPlugin = require("./CommonJsChunkLoadingPlugin");
|
2017-01-08 00:06:08 +08:00
|
|
|
|
2018-11-09 05:59:19 +08:00
|
|
|
/** @typedef {import("../Compiler")} Compiler */
|
|
|
|
|
2017-01-08 00:06:08 +08:00
|
|
|
class NodeTemplatePlugin {
|
|
|
|
constructor(options) {
|
2020-08-25 19:20:29 +08:00
|
|
|
this._options = options || {};
|
2017-01-08 00:06:08 +08:00
|
|
|
}
|
|
|
|
|
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}
|
|
|
|
*/
|
2017-01-08 00:06:08 +08:00
|
|
|
apply(compiler) {
|
2020-08-25 19:37:40 +08:00
|
|
|
compiler.options.output.chunkLoading = this._options.asyncChunkLoading
|
|
|
|
? "async-node"
|
|
|
|
: "require";
|
2020-08-25 16:30:56 +08:00
|
|
|
new CommonJsChunkFormatPlugin().apply(compiler);
|
2020-08-25 19:20:29 +08:00
|
|
|
new CommonJsChunkLoadingPlugin(this._options).apply(compiler);
|
2017-01-08 00:06:08 +08:00
|
|
|
}
|
2013-01-31 01:49:25 +08:00
|
|
|
}
|
2017-01-08 00:06:08 +08:00
|
|
|
|
2013-03-01 16:44:58 +08:00
|
|
|
module.exports = NodeTemplatePlugin;
|