| 
									
										
										
										
											2020-09-21 04:08:38 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */ | 
					
						
							|  |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-23 20:03:37 +08:00
										 |  |  | const PLUGIN_NAME = "IgnoreWarningsPlugin"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-21 04:08:38 +08:00
										 |  |  | class IgnoreWarningsPlugin { | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {IgnoreWarningsNormalized} ignoreWarnings conditions to ignore warnings | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	constructor(ignoreWarnings) { | 
					
						
							|  |  |  | 		this._ignoreWarnings = ignoreWarnings; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-21 04:08:38 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 		compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { | 
					
						
							|  |  |  | 			compilation.hooks.processWarnings.tap(PLUGIN_NAME, (warnings) => | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 				warnings.filter( | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 					(warning) => | 
					
						
							|  |  |  | 						!this._ignoreWarnings.some((ignore) => ignore(warning, compilation)) | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 				) | 
					
						
							| 
									
										
										
										
											2020-09-21 04:08:38 +08:00
										 |  |  | 			); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = IgnoreWarningsPlugin; |