2013-01-31 01:49:25 +08:00
|
|
|
/*
|
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
|
*/
|
2017-01-11 23:28:02 +08:00
|
|
|
"use strict";
|
2013-01-31 01:49:25 +08:00
|
|
|
|
2017-01-11 23:28:02 +08:00
|
|
|
const FunctionModuleTemplatePlugin = require("./FunctionModuleTemplatePlugin");
|
|
|
|
|
const RequestShortener = require("./RequestShortener");
|
|
|
|
|
|
|
|
|
|
class FunctionModulePlugin {
|
|
|
|
|
constructor(options, requestShortener) {
|
|
|
|
|
this.options = options;
|
|
|
|
|
this.requestShortener = requestShortener;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply(compiler) {
|
|
|
|
|
compiler.plugin("compilation", (compilation) => {
|
2017-11-11 18:27:02 +08:00
|
|
|
compilation.moduleTemplates.javascript.requestShortener = this.requestShortener || new RequestShortener(compiler.context);
|
|
|
|
|
compilation.moduleTemplates.javascript.apply(new FunctionModuleTemplatePlugin());
|
2017-01-11 23:28:02 +08:00
|
|
|
});
|
|
|
|
|
}
|
2013-01-31 01:49:25 +08:00
|
|
|
}
|
2017-01-11 23:28:02 +08:00
|
|
|
|
2013-01-31 01:49:25 +08:00
|
|
|
module.exports = FunctionModulePlugin;
|