1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import type { Plugin } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import vueJsx from '@vitejs/plugin-vue-jsx';
- import Components from 'unplugin-vue-components/vite';
- import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
- import AutoImport from 'unplugin-auto-import/vite';
- import legacy from '@vitejs/plugin-legacy';
- export function createVitePlugins(isBuild: boolean, mode: string): Plugin[] {
- const plugins = [
- vue(),
- vueJsx(),
- Components({
- dirs: ['src/components'],
- extensions: ['vue'],
- deep: true,
- resolvers: [
- AntDesignVueResolver({
- // 用于less变更主题用
- importStyle: 'less',
- /**
- * resolve `ant-design-vue' icons
- * requires package `@ant-design/icons-vue`
- */
- resolveIcons: true
- })
- ],
- dts: 'src/components.d.ts'
- }),
- AutoImport({
- imports: [
- 'vue',
- 'vue-router',
- {
- '@vueuse/core': ['useLocalStorage', 'useClipboard']
- }
- ],
- dts: 'src/auto-imports.d.ts'
- })
- ];
- if (isBuild && mode === 'legacy') {
- plugins.push(
- legacy({
- targets: ['ie >= 11'],
- additionalLegacyPolyfills: ['regenerator-runtime/runtime']
- })
- );
- }
- return plugins;
- }
|