wireguard-dashboard-admin/build/plugin/index.js

41 lines
918 B
JavaScript
Raw Normal View History

2022-01-08 17:20:46 +08:00
import vue from '@vitejs/plugin-vue'
2022-06-11 16:55:36 +08:00
/**
* * unocss插件原子css
* https://github.com/antfu/unocss
*/
import Unocss from 'unocss/vite'
2022-04-19 21:50:19 +08:00
// rollup打包分析插件
import visualizer from 'rollup-plugin-visualizer'
2022-08-27 11:04:07 +08:00
// 压缩
import viteCompression from 'vite-plugin-compression'
2022-04-19 21:50:19 +08:00
2022-01-08 17:20:46 +08:00
import { configHtmlPlugin } from './html'
import { configMockPlugin } from './mock'
import unplugin from './unplugin'
2022-01-08 17:20:46 +08:00
export function createVitePlugins(viteEnv, isBuild) {
const plugins = [vue(), ...unplugin, configHtmlPlugin(viteEnv, isBuild), Unocss()]
2022-08-27 14:09:32 +08:00
if (viteEnv?.VITE_USE_MOCK) {
plugins.push(configMockPlugin(isBuild))
}
2022-01-08 17:20:46 +08:00
2022-08-27 11:04:07 +08:00
if (viteEnv.VITE_USE_COMPRESS) {
plugins.push(viteCompression({ algorithm: viteEnv.VITE_COMPRESS_TYPE || 'gzip' }))
}
2022-04-19 21:50:19 +08:00
if (isBuild) {
plugins.push(
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
})
)
}
2022-01-08 17:20:46 +08:00
return plugins
}