From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 build/vite/index.ts |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/build/vite/index.ts b/build/vite/index.ts
new file mode 100644
index 0000000..c064cc5
--- /dev/null
+++ b/build/vite/index.ts
@@ -0,0 +1,99 @@
+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'
+// @ts-ignore
+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-ng'
+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?$/, // .ts, .tsx, .js, .jsx
+        /\.vue$/,
+        /\.vue\?vue/, // .vue
+        /\.md$/ // .md
+      ],
+      imports: [
+        'vue',
+        'vue-router',
+        // 鍙澶栨坊鍔犻渶瑕� autoImport 鐨勭粍浠�
+        {
+          '@/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, // Default `false`
+        filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
+        globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
+      }
+    }),
+    Components({
+      // 鐢熸垚鑷畾涔� `auto-components.d.ts` 鍏ㄥ眬澹版槑
+      dts: 'src/types/auto-components.d.ts',
+      // 鑷畾涔夌粍浠剁殑瑙f瀽鍣�
+      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]',
+    }),
+    viteCompression({
+      verbose: true, // 鏄惁鍦ㄦ帶鍒跺彴杈撳嚭鍘嬬缉缁撴灉
+      disable: false, // 鏄惁绂佺敤
+      threshold: 10240, // 浣撶Н澶т簬 threshold 鎵嶄細琚帇缂�,鍗曚綅 b
+      algorithm: 'gzip', // 鍘嬬缉绠楁硶,鍙�� [ 'gzip' , 'brotliCompress' ,'deflate' , 'deflateRaw']
+      ext: '.gz', // 鐢熸垚鐨勫帇缂╁寘鍚庣紑
+      deleteOriginFile: false //鍘嬬缉鍚庢槸鍚﹀垹闄ゆ簮鏂囦欢
+    }),
+    ViteEjsPlugin(),
+    topLevelAwait({
+      // https://juejin.cn/post/7152191742513512485
+      // The export name of top-level await promise for each chunk module
+      promiseExportName: '__tla',
+      // The function to generate import names of top-level await promise in each chunk module
+      promiseImportName: (i) => `__tla_${i}`
+    })
+  ]
+}

--
Gitblit v1.8.0