| 
									
										
										
										
											2021-04-14 20:37:11 +08:00
										 |  |  | /** @type {import("../../../../").Configuration} */ | 
					
						
							|  |  |  | module.exports = { | 
					
						
							|  |  |  | 	module: { | 
					
						
							|  |  |  | 		generator: { | 
					
						
							|  |  |  | 			asset: { | 
					
						
							|  |  |  | 				filename: "assets/[name][ext]" | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: [ | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2021-10-08 19:53:33 +08:00
										 |  |  | 				oneOf: [ | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						test: /\.css\.js$/, | 
					
						
							|  |  |  | 						use: "./loader", | 
					
						
							|  |  |  | 						type: "asset/source" | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					{ test: /\.(js|jpg|png)$/ }, | 
					
						
							|  |  |  | 					{ type: "asset/resource" } | 
					
						
							|  |  |  | 				] | 
					
						
							| 
									
										
										
										
											2021-04-14 20:37:11 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	plugins: [ | 
					
						
							|  |  |  | 		compiler => | 
					
						
							|  |  |  | 			compiler.hooks.done.tap("test case", stats => { | 
					
						
							|  |  |  | 				const png = stats.compilation.getAsset("assets/file.png"); | 
					
						
							|  |  |  | 				const jpg = stats.compilation.getAsset("assets/file.jpg"); | 
					
						
							|  |  |  | 				if (png) { | 
					
						
							|  |  |  | 					expect(jpg).toBe(undefined); | 
					
						
							|  |  |  | 					expect(png).toHaveProperty( | 
					
						
							|  |  |  | 						"info", | 
					
						
							|  |  |  | 						expect.objectContaining({ sourceFilename: "file.png" }) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					expect(jpg).toHaveProperty( | 
					
						
							|  |  |  | 						"info", | 
					
						
							|  |  |  | 						expect.objectContaining({ sourceFilename: "file.jpg" }) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 	] | 
					
						
							|  |  |  | }; |