2022-01-08 17:20:46 +08:00
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
2022-02-21 11:25:06 +08:00
|
|
|
|
|
2022-04-08 19:35:22 +08:00
|
|
|
|
/**
|
|
|
|
|
* * 扩展setup插件,支持在script标签中使用name属性
|
|
|
|
|
* usage: <script setup name="MyComp"></script>
|
|
|
|
|
*/
|
2022-07-01 15:07:01 +08:00
|
|
|
|
import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'
|
2022-04-08 19:35:22 +08:00
|
|
|
|
|
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-01-08 17:20:46 +08:00
|
|
|
|
import { configHtmlPlugin } from './html'
|
|
|
|
|
import { configMockPlugin } from './mock'
|
2022-06-19 13:35:36 +08:00
|
|
|
|
import unplugin from './unplugin'
|
2022-01-08 17:20:46 +08:00
|
|
|
|
|
|
|
|
|
export function createVitePlugins(viteEnv, isBuild) {
|
2022-07-01 15:07:01 +08:00
|
|
|
|
const plugins = [vue(), vueSetupExtend(), ...unplugin, configHtmlPlugin(viteEnv, isBuild), Unocss()]
|
2022-06-19 13:35:36 +08:00
|
|
|
|
|
|
|
|
|
if (viteEnv?.VITE_APP_USE_MOCK) {
|
|
|
|
|
plugins.push(configMockPlugin(isBuild))
|
|
|
|
|
}
|
2022-01-08 17:20:46 +08:00
|
|
|
|
|
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
|
|
|
|
|
}
|