| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const RuntimeGlobals = require("../RuntimeGlobals"); | 
					
						
							|  |  |  | const RuntimeModule = require("../RuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-12-18 05:05:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | class PublicPathRuntimeModule extends RuntimeModule { | 
					
						
							| 
									
										
										
										
											2020-09-18 15:48:53 +08:00
										 |  |  | 	constructor() { | 
					
						
							| 
									
										
										
										
											2020-12-11 21:32:42 +08:00
										 |  |  | 		super("publicPath", RuntimeModule.STAGE_BASIC); | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} runtime code | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	generate() { | 
					
						
							| 
									
										
										
										
											2020-09-18 15:48:53 +08:00
										 |  |  | 		const { compilation } = this; | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 		const { publicPath } = compilation.outputOptions; | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 		return `${RuntimeGlobals.publicPath} = ${JSON.stringify( | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 			this.compilation.getPath(publicPath || "", { | 
					
						
							|  |  |  | 				hash: this.compilation.hash || "XXXX" | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 		)};`;
 | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = PublicPathRuntimeModule; |