webpack/lib/LoaderTargetPlugin.js

35 lines
661 B
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
2018-07-30 23:08:51 +08:00
"use strict";
2018-11-09 05:59:19 +08:00
/** @typedef {import("./Compiler")} Compiler */
class LoaderTargetPlugin {
2018-11-09 05:59:19 +08:00
/**
* @param {string} target the target
*/
constructor(target) {
this.target = target;
}
2018-11-09 05:59:19 +08:00
/**
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
2018-02-25 09:00:20 +08:00
compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => {
compilation.hooks.normalModuleLoader.tap(
"LoaderTargetPlugin",
loaderContext => {
loaderContext.target = this.target;
}
);
});
}
}
module.exports = LoaderTargetPlugin;