You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
55 lines
1.4 KiB
import vue from '@vitejs/plugin-vue';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import { type PluginOption } from 'vite';
|
|
import purgeIcons from 'vite-plugin-purge-icons';
|
|
|
|
import { createAppConfigPlugin } from './appConfig';
|
|
import { configCompressPlugin } from './compress';
|
|
import { configHtmlPlugin } from './html';
|
|
import { configSvgIconsPlugin } from './svgSprite';
|
|
import { configVisualizerConfig } from './visualizer';
|
|
// import DevTools from 'vite-plugin-vue-devtools';
|
|
|
|
interface Options {
|
|
isBuild: boolean;
|
|
root: string;
|
|
compress: string;
|
|
enableAnalyze?: boolean;
|
|
}
|
|
|
|
async function createPlugins({ isBuild, root, compress, enableAnalyze }: Options) {
|
|
const vitePlugins: (PluginOption | PluginOption[])[] = [vue(), vueJsx()];
|
|
|
|
const appConfigPlugin = await createAppConfigPlugin({ root, isBuild });
|
|
vitePlugins.push(appConfigPlugin);
|
|
|
|
// vitePlugins.push(DevTools());
|
|
|
|
// vite-plugin-html
|
|
vitePlugins.push(configHtmlPlugin({ isBuild }));
|
|
|
|
// vite-plugin-svg-icons
|
|
vitePlugins.push(configSvgIconsPlugin({ isBuild }));
|
|
|
|
// vite-plugin-purge-icons
|
|
vitePlugins.push(purgeIcons());
|
|
|
|
// The following plugins only work in the production environment
|
|
if (isBuild) {
|
|
// rollup-plugin-gzip
|
|
vitePlugins.push(
|
|
configCompressPlugin({
|
|
compress,
|
|
}),
|
|
);
|
|
}
|
|
|
|
// rollup-plugin-visualizer
|
|
if (enableAnalyze) {
|
|
vitePlugins.push(configVisualizerConfig());
|
|
}
|
|
|
|
return vitePlugins;
|
|
}
|
|
|
|
export { createPlugins };
|
|
|