huiyi-h5/build/vite/index.ts

67 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2024-02-10 08:25:41 +00:00
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { visualizer } from 'rollup-plugin-visualizer'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import VueRouter from 'unplugin-vue-router/vite'
import { VueRouterAutoImports } from 'unplugin-vue-router'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import { unheadVueComposablesImports } from '@unhead/vue'
import VueDevTools from 'vite-plugin-vue-devtools'
import mockDevServerPlugin from 'vite-plugin-mock-dev-server'
import UnoCSS from 'unocss/vite'
import { createViteVConsole } from './vconsole'
export function createVitePlugins() {
return [
VueRouter({
routesFolder: 'src/views',
dts: 'src/typed-router.d.ts',
}),
vue(),
vueJsx(),
visualizer(),
UnoCSS(),
mockDevServerPlugin(),
legacy({
targets: ['defaults', 'not IE 11'],
}),
Components({
extensions: ['vue'],
resolvers: [VantResolver()],
include: [/\.vue$/, /\.vue\?vue/],
dts: 'src/components.d.ts',
}),
AutoImport({
include: [
/\.[tj]sx?$/,
/\.vue$/,
/\.vue\?vue/,
],
imports: [
'vue',
'vitest',
'@vueuse/core',
VueRouterAutoImports,
{
'vue-router/auto': ['useLink'],
},
unheadVueComposablesImports,
],
dts: 'src/auto-imports.d.ts',
dirs: [
'src/composables',
],
}),
createViteVConsole(),
VueDevTools(),
]
}