basic2/vite/plugins/index.ts
2022-09-26 00:21:50 +08:00

39 lines
1.3 KiB
TypeScript

import type { PluginOption } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import createRestart from './restart'
import createHtml from './html'
import createAutoImport from './auto-import'
import createComponents from './components'
import createSetupExtend from './setup-extend'
import createSvgIcon from './svg-icon'
import createMock from './mock'
import createLayouts from './layouts'
import createPages from './pages'
import createCompression from './compression'
import createSpritesmith from './spritesmith'
import createBanner from './banner'
export default function createVitePlugins(viteEnv, isBuild = false) {
const vitePlugins: (PluginOption | PluginOption[])[] = [
vue({
reactivityTransform: true,
}),
vueJsx(),
]
!isBuild && vitePlugins.push(createRestart())
vitePlugins.push(createHtml(viteEnv, isBuild))
vitePlugins.push(createAutoImport())
vitePlugins.push(createComponents())
vitePlugins.push(createSetupExtend())
vitePlugins.push(createSvgIcon(isBuild))
vitePlugins.push(createMock(viteEnv, isBuild))
vitePlugins.push(createLayouts())
vitePlugins.push(createPages())
isBuild && vitePlugins.push(...createCompression(viteEnv))
vitePlugins.push(...createSpritesmith(isBuild))
vitePlugins.push(createBanner())
return vitePlugins
}