| 
									
										
										
										
											2014-06-03 03:23:53 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var ConcatSource = require("webpack-core/lib/ConcatSource"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function JsonpExportMainTemplatePlugin(name) { | 
					
						
							|  |  |  | 	this.name = name; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = JsonpExportMainTemplatePlugin; | 
					
						
							| 
									
										
										
										
											2014-12-22 23:10:23 +08:00
										 |  |  | JsonpExportMainTemplatePlugin.prototype.apply = function(compilation) { | 
					
						
							|  |  |  | 	var mainTemplate = compilation.mainTemplate; | 
					
						
							|  |  |  | 	compilation.templatesPlugin("render-with-entry", function(source, chunk, hash) { | 
					
						
							| 
									
										
										
										
											2014-10-13 07:51:16 +08:00
										 |  |  | 		var name = mainTemplate.applyPluginsWaterfall("asset-path", this.name || "", { | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | 			hash: hash, | 
					
						
							|  |  |  | 			chunk: chunk | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2014-06-03 03:23:53 +08:00
										 |  |  | 		return new ConcatSource(name + "(", source, ");"); | 
					
						
							|  |  |  | 	}.bind(this)); | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | 	mainTemplate.plugin("global-hash-paths", function(paths) { | 
					
						
							|  |  |  | 		if (this.name) paths.push(this.name); | 
					
						
							|  |  |  | 		return paths; | 
					
						
							| 
									
										
										
										
											2014-06-03 03:23:53 +08:00
										 |  |  | 	}.bind(this)); | 
					
						
							|  |  |  | 	mainTemplate.plugin("hash", function(hash) { | 
					
						
							|  |  |  | 		hash.update("jsonp export"); | 
					
						
							|  |  |  | 		hash.update(this.name + ""); | 
					
						
							|  |  |  | 	}.bind(this)); | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | }; |