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.
42 lines
1.2 KiB
42 lines
1.2 KiB
import type { PluginOption } from 'vite' |
|
import vue from '@vitejs/plugin-vue' |
|
import vueJsx from '@vitejs/plugin-vue-jsx' |
|
import UnoCSS from 'unocss/vite' |
|
import { configPwaConfig } from './pwa' |
|
import { configHtmlPlugin } from './html' |
|
import { configCompressPlugin } from './compress' |
|
import { configVisualizerConfig } from './visualizer' |
|
import { configSvgIconsPlugin } from './svgSprite' |
|
|
|
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
|
const { VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv |
|
|
|
const vitePlugins: PluginOption[] = [ |
|
// have to |
|
vue(), |
|
// have to |
|
vueJsx(), |
|
// UnoCSS |
|
UnoCSS(), |
|
] |
|
|
|
// vite-vue-plugin-html |
|
vitePlugins.push(configHtmlPlugin({ isBuild })) |
|
|
|
// vite-plugin-svg-icons |
|
vitePlugins.push(configSvgIconsPlugin(isBuild)) |
|
|
|
// 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)) |
|
|
|
// vite-plugin-pwa |
|
vitePlugins.push(configPwaConfig(viteEnv)) |
|
} |
|
|
|
return vitePlugins |
|
}
|
|
|