mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 18:40:22 +08:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { PluginOption } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import purgeIcons from 'vite-plugin-purge-icons';
|
|
import windiCSS from 'vite-plugin-windicss';
|
|
import { configHtmlPlugin } from './html';
|
|
import { configMockPlugin } from './mock';
|
|
import { configCompressPlugin } from './compress';
|
|
import { configVisualizerConfig } from './visualizer';
|
|
import { configSvgIconsPlugin } from './svgSprite';
|
|
|
|
export async function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
|
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
|
|
|
|
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
|
// have to
|
|
vue(),
|
|
// have to
|
|
vueJsx(),
|
|
];
|
|
|
|
// vite-plugin-windicss
|
|
vitePlugins.push(windiCSS());
|
|
|
|
// vite-plugin-html
|
|
vitePlugins.push(configHtmlPlugin(viteEnv, isBuild));
|
|
|
|
// vite-plugin-svg-icons
|
|
vitePlugins.push(configSvgIconsPlugin(isBuild));
|
|
|
|
// vite-plugin-mock
|
|
VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild));
|
|
|
|
// vite-plugin-purge-icons
|
|
vitePlugins.push(purgeIcons());
|
|
|
|
// rollup-plugin-visualizer
|
|
vitePlugins.push(configVisualizerConfig());
|
|
|
|
// The following plugins only work in the production environment
|
|
if (isBuild) {
|
|
// rollup-plugin-gzip
|
|
vitePlugins.push(
|
|
configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE),
|
|
);
|
|
}
|
|
|
|
return vitePlugins;
|
|
}
|