up
This commit is contained in:
		
							
								
								
									
										12
									
								
								vite/plugins/auto-import.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										12
									
								
								vite/plugins/auto-import.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| import autoImport from 'unplugin-auto-import/vite' | ||||
|  | ||||
| export default function createAutoImport() { | ||||
|     return autoImport({ | ||||
|         imports: [ | ||||
|             'vue', | ||||
|             'vue-router', | ||||
|             'pinia' | ||||
|         ], | ||||
|         dts: false | ||||
|     }) | ||||
| } | ||||
							
								
								
									
										28
									
								
								vite/plugins/compression.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								vite/plugins/compression.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| import compression from 'vite-plugin-compression' | ||||
|  | ||||
| export default function createCompression(env) { | ||||
|     const { VITE_BUILD_COMPRESS } = env | ||||
|     const plugin = [] | ||||
|     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 | ||||
| } | ||||
							
								
								
									
										15
									
								
								vite/plugins/index.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								vite/plugins/index.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| import vue from '@vitejs/plugin-vue' | ||||
|  | ||||
| import createAutoImport from './auto-import' | ||||
| import createSvgIcon from './svg-icon' | ||||
| import createCompression from './compression' | ||||
| import createSetupExtend from './setup-extend' | ||||
|  | ||||
| export default function createVitePlugins(viteEnv, isBuild = false) { | ||||
|     const vitePlugins = [vue()] | ||||
|     vitePlugins.push(createAutoImport()) | ||||
| 	vitePlugins.push(createSetupExtend()) | ||||
|     vitePlugins.push(createSvgIcon(isBuild)) | ||||
| 	isBuild && vitePlugins.push(...createCompression(viteEnv)) | ||||
|     return vitePlugins | ||||
| } | ||||
							
								
								
									
										5
									
								
								vite/plugins/setup-extend.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								vite/plugins/setup-extend.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| import setupExtend from 'vite-plugin-vue-setup-extend' | ||||
|  | ||||
| export default function createSetupExtend() { | ||||
|     return setupExtend() | ||||
| } | ||||
							
								
								
									
										10
									
								
								vite/plugins/svg-icon.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vite/plugins/svg-icon.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' | ||||
| import path from 'path' | ||||
|  | ||||
| export default function createSvgIcon(isBuild) { | ||||
|     return createSvgIconsPlugin({ | ||||
| 		iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')], | ||||
|         symbolId: 'icon-[dir]-[name]', | ||||
|         svgoOptions: isBuild | ||||
|     }) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user