| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-19 11:28:55 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | const NormalModule = require("./NormalModule"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-09 05:59:19 +08:00
										 |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-19 11:28:55 +08:00
										 |  |  | class LoaderTargetPlugin { | 
					
						
							| 
									
										
										
										
											2018-11-09 05:59:19 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string} target the target | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-19 11:28:55 +08:00
										 |  |  | 	constructor(target) { | 
					
						
							|  |  |  | 		this.target = target; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-19 11:28:55 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => { | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | 			NormalModule.getCompilationHooks(compilation).loader.tap( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				"LoaderTargetPlugin", | 
					
						
							|  |  |  | 				loaderContext => { | 
					
						
							|  |  |  | 					loaderContext.target = this.target; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-01-19 11:28:55 +08:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-19 11:28:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | module.exports = LoaderTargetPlugin; |