| 
									
										
										
										
											2023-04-03 00:05:09 +08:00
										 |  |  | import compression from 'vite-plugin-compression'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-14 08:17:12 +00:00
										 |  |  | export default (env: any) => { | 
					
						
							| 
									
										
										
										
											2023-04-03 00:05:09 +08:00
										 |  |  |   const { VITE_BUILD_COMPRESS } = env; | 
					
						
							|  |  |  |   const plugin: any[] = []; | 
					
						
							|  |  |  |   if (VITE_BUILD_COMPRESS) { | 
					
						
							|  |  |  |     const compressList = VITE_BUILD_COMPRESS.split(','); | 
					
						
							|  |  |  |     if (compressList.includes('gzip')) { | 
					
						
							|  |  |  |       // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
 | 
					
						
							|  |  |  |       plugin.push( | 
					
						
							|  |  |  |         compression({ | 
					
						
							|  |  |  |           ext: '.gz', | 
					
						
							|  |  |  |           deleteOriginFile: false | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (compressList.includes('brotli')) { | 
					
						
							|  |  |  |       plugin.push( | 
					
						
							|  |  |  |         compression({ | 
					
						
							|  |  |  |           ext: '.br', | 
					
						
							|  |  |  |           algorithm: 'brotliCompress', | 
					
						
							|  |  |  |           deleteOriginFile: false | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return plugin; | 
					
						
							| 
									
										
										
										
											2023-12-14 08:17:12 +00:00
										 |  |  | }; |