| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-05 06:23:48 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FlagIncludedChunksPlugin { | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 06:23:48 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							|  |  |  | 		compiler.plugin("compilation", (compilation) => { | 
					
						
							|  |  |  | 			compilation.plugin("optimize-chunk-ids", (chunks) => { | 
					
						
							|  |  |  | 				chunks.forEach((chunkA) => { | 
					
						
							|  |  |  | 					chunks.forEach((chunkB) => { | 
					
						
							|  |  |  | 						if(chunkA === chunkB) return; | 
					
						
							|  |  |  | 						// is chunkB in chunkA?
 | 
					
						
							|  |  |  | 						if(chunkA.modules.length < chunkB.modules.length) return; | 
					
						
							|  |  |  | 						for(let i = 0; i < chunkB.modules.length; i++) { | 
					
						
							|  |  |  | 							if(chunkA.modules.indexOf(chunkB.modules[i]) < 0) return; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						chunkA.ids.push(chunkB.id); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-05 06:23:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = FlagIncludedChunksPlugin; |