| 
									
										
										
										
											2015-06-28 04:47:51 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2016-12-29 15:05:11 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NamedModulesPlugin { | 
					
						
							|  |  |  | 	constructor(options) { | 
					
						
							|  |  |  | 		this.options = options || {}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap("NamedModulesPlugin", compilation => { | 
					
						
							|  |  |  | 			compilation.hooks.beforeModuleIds.tap("NamedModulesPlugin", modules => { | 
					
						
							|  |  |  | 				for (const module of modules) { | 
					
						
							|  |  |  | 					if (module.id === null && module.libIdent) { | 
					
						
							| 
									
										
										
										
											2016-12-29 15:05:11 +08:00
										 |  |  | 						module.id = module.libIdent({ | 
					
						
							|  |  |  | 							context: this.options.context || compiler.options.context | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-12-29 15:05:11 +08:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-06-28 04:47:51 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-12-29 15:05:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-28 04:47:51 +08:00
										 |  |  | module.exports = NamedModulesPlugin; |