123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import { resolve } from 'path'
- import Vue from '@vitejs/plugin-vue'
- import VueJsx from '@vitejs/plugin-vue-jsx'
- import progress from 'vite-plugin-progress'
- import EslintPlugin from 'vite-plugin-eslint'
- import PurgeIcons from 'vite-plugin-purge-icons'
- import { ViteEjsPlugin } from 'vite-plugin-ejs'
- import ElementPlus from 'unplugin-element-plus/vite'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
- import viteCompression from 'vite-plugin-compression'
- import topLevelAwait from 'vite-plugin-top-level-await'
- import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
- import UnoCSS from 'unocss/vite'
- export function createVitePlugins() {
- const root = process.cwd()
-
- function pathResolve(dir: string) {
- return resolve(root, '.', dir)
- }
- return [
- Vue(),
- VueJsx(),
- UnoCSS(),
- progress(),
- PurgeIcons(),
- ElementPlus({}),
- AutoImport({
- include: [
- /\.[tj]sx?$/,
- /\.vue$/,
- /\.vue\?vue/,
- /\.md$/
- ],
- imports: [
- 'vue',
- 'vue-router',
-
- {
- '@/hooks/web/useI18n': ['useI18n'],
- '@/hooks/web/useMessage': ['useMessage'],
- '@/hooks/web/useTable': ['useTable'],
- '@/hooks/web/useCrudSchemas': ['useCrudSchemas'],
- '@/utils/formRules': ['required'],
- '@/utils/dict': ['DICT_TYPE']
- }
- ],
- dts: 'src/types/auto-imports.d.ts',
- resolvers: [ElementPlusResolver()],
- eslintrc: {
- enabled: false,
- filepath: './.eslintrc-auto-import.json',
- globalsPropValue: true
- }
- }),
- Components({
-
- dts: 'src/types/auto-components.d.ts',
-
- resolvers: [ElementPlusResolver()],
- globs: ["src/components/**/**.{vue, md}", '!src/components/DiyEditor/components/mobile/**']
- }),
- EslintPlugin({
- cache: false,
- include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx']
- }),
- VueI18nPlugin({
- runtimeOnly: true,
- compositionOnly: true,
- include: [resolve(__dirname, 'src/locales/**')]
- }),
- createSvgIconsPlugin({
- iconDirs: [pathResolve('src/assets/svgs')],
- symbolId: 'icon-[dir]-[name]',
- svgoOptions: true
- }),
- viteCompression({
- verbose: true,
- disable: false,
- threshold: 10240,
- algorithm: 'gzip',
- ext: '.gz',
- deleteOriginFile: false
- }),
- ViteEjsPlugin(),
- topLevelAwait({
-
-
- promiseExportName: '__tla',
-
- promiseImportName: (i) => `__tla_${i}`
- })
- ]
- }
|