UNPKG

747 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const NormalModule = require("./NormalModule");
9
10/** @typedef {import("./Compiler")} Compiler */
11
12class LoaderTargetPlugin {
13 /**
14 * @param {string} target the target
15 */
16 constructor(target) {
17 this.target = target;
18 }
19
20 /**
21 * Apply the plugin
22 * @param {Compiler} compiler the compiler instance
23 * @returns {void}
24 */
25 apply(compiler) {
26 compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => {
27 NormalModule.getCompilationHooks(compilation).loader.tap(
28 "LoaderTargetPlugin",
29 loaderContext => {
30 loaderContext.target = this.target;
31 }
32 );
33 });
34 }
35}
36
37module.exports = LoaderTargetPlugin;