| 
									
										
										
										
											2025-04-22 18:49:30 +08:00
										 |  |  | const MCEP = require("mini-css-extract-plugin"); | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-01 22:36:51 +08:00
										 |  |  | /** @typedef {import("../../../../").StatsCompilation} StatsCompilation */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-16 22:04:11 +08:00
										 |  |  | /** @type {(i: number, options?: import("mini-css-extract-plugin").PluginOptions) => import("../../../../").Configuration} */ | 
					
						
							| 
									
										
										
										
											2021-09-03 15:21:40 +08:00
										 |  |  | const config = (i, options) => ({ | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 	entry: { | 
					
						
							|  |  |  | 		a: "./a", | 
					
						
							|  |  |  | 		b: "./b", | 
					
						
							| 
									
										
										
										
											2021-01-12 00:20:51 +08:00
										 |  |  | 		c: "./c.css", | 
					
						
							|  |  |  | 		x: "./x" // also imports chunk but with different exports
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	output: { | 
					
						
							| 
									
										
										
										
											2024-07-24 20:50:02 +08:00
										 |  |  | 		filename: `${i}_[name].js`, | 
					
						
							|  |  |  | 		pathinfo: false | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	module: { | 
					
						
							|  |  |  | 		rules: [ | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2021-10-08 19:53:33 +08:00
										 |  |  | 				oneOf: [ | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						test: /\.css$/, | 
					
						
							|  |  |  | 						use: [MCEP.loader, "css-loader"] | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					{ test: /\.js$/ }, | 
					
						
							|  |  |  | 					{ type: "asset" } | 
					
						
							|  |  |  | 				] | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2021-01-12 00:20:51 +08:00
										 |  |  | 	optimization: { | 
					
						
							|  |  |  | 		chunkIds: "named" | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:52:19 +08:00
										 |  |  | 	target: "web", | 
					
						
							|  |  |  | 	node: { | 
					
						
							|  |  |  | 		__dirname: false | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2021-01-12 00:20:51 +08:00
										 |  |  | 	plugins: [ | 
					
						
							| 
									
										
										
										
											2021-09-03 15:21:40 +08:00
										 |  |  | 		new MCEP(options), | 
					
						
							| 
									
										
										
										
											2021-01-12 00:20:51 +08:00
										 |  |  | 		compiler => { | 
					
						
							|  |  |  | 			compiler.hooks.done.tap("Test", stats => { | 
					
						
							| 
									
										
										
										
											2025-05-01 22:36:51 +08:00
										 |  |  | 				const chunkIds = | 
					
						
							|  |  |  | 					/** @type {NonNullable<StatsCompilation["chunks"]>} */ | 
					
						
							|  |  |  | 					(stats.toJson({ all: false, chunks: true, ids: true }).chunks) | 
					
						
							|  |  |  | 						.map(c => c.id) | 
					
						
							|  |  |  | 						.sort(); | 
					
						
							| 
									
										
										
										
											2021-01-12 00:20:51 +08:00
										 |  |  | 				expect(chunkIds).toEqual([ | 
					
						
							|  |  |  | 					"a", | 
					
						
							|  |  |  | 					"b", | 
					
						
							|  |  |  | 					"c", | 
					
						
							|  |  |  | 					"chunk_js-_43b60", | 
					
						
							|  |  |  | 					"chunk_js-_43b61", | 
					
						
							|  |  |  | 					"chunk_js-_43b62", | 
					
						
							|  |  |  | 					"d_css", | 
					
						
							|  |  |  | 					"x" | 
					
						
							|  |  |  | 				]); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	] | 
					
						
							| 
									
										
										
										
											2021-09-03 15:21:40 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = [ | 
					
						
							|  |  |  | 	config(0), | 
					
						
							|  |  |  | 	config(1, { | 
					
						
							|  |  |  | 		experimentalUseImportModule: true | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | ]; |