|
|
|
@ -4,6 +4,8 @@ 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 { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
|
|
|
|
import { ViteEjsPlugin } from 'vite-plugin-ejs' |
|
|
|
// @ts-ignore
|
|
|
|
import ElementPlus from 'unplugin-element-plus/vite' |
|
|
|
@ -14,8 +16,18 @@ 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 { IconJson } from '../../src/components/Icon/src/data.ts' |
|
|
|
|
|
|
|
import UnoCSS from 'unocss/vite' |
|
|
|
|
|
|
|
const preloadOfflineIcons = (iconData: Record<string, string[]>): string[] => { |
|
|
|
return Object.entries(iconData).reduce((a: string[], [k, v]) => { |
|
|
|
a = a.concat(v.map((i) => k + i)) |
|
|
|
return a |
|
|
|
}, []) |
|
|
|
} |
|
|
|
|
|
|
|
export function createVitePlugins() { |
|
|
|
const root = process.cwd() |
|
|
|
|
|
|
|
@ -29,7 +41,9 @@ export function createVitePlugins() { |
|
|
|
VueJsx(), |
|
|
|
UnoCSS(), |
|
|
|
progress(), |
|
|
|
PurgeIcons(), |
|
|
|
PurgeIcons({ |
|
|
|
included: preloadOfflineIcons(IconJson) |
|
|
|
}), |
|
|
|
ElementPlus({}), |
|
|
|
AutoImport({ |
|
|
|
include: [ |
|
|
|
@ -64,7 +78,7 @@ export function createVitePlugins() { |
|
|
|
dts: 'src/types/auto-components.d.ts', |
|
|
|
// 自定义组件的解析器
|
|
|
|
resolvers: [ElementPlusResolver()], |
|
|
|
globs: ["src/components/**/**.{vue, md}", '!src/components/DiyEditor/components/mobile/**'] |
|
|
|
globs: ['src/components/**/**.{vue, md}', '!src/components/DiyEditor/components/mobile/**'] |
|
|
|
}), |
|
|
|
// EslintPlugin({
|
|
|
|
// cache: false,
|
|
|
|
@ -77,7 +91,7 @@ export function createVitePlugins() { |
|
|
|
}), |
|
|
|
createSvgIconsPlugin({ |
|
|
|
iconDirs: [pathResolve('src/assets/svgs')], |
|
|
|
symbolId: 'icon-[dir]-[name]', |
|
|
|
symbolId: 'icon-[dir]-[name]' |
|
|
|
}), |
|
|
|
// viteCompression({
|
|
|
|
// verbose: true, // 是否在控制台输出压缩结果
|
|
|
|
@ -94,6 +108,13 @@ export function createVitePlugins() { |
|
|
|
promiseExportName: '__tla', |
|
|
|
// The function to generate import names of top-level await promise in each chunk module
|
|
|
|
promiseImportName: (i) => `__tla_${i}` |
|
|
|
}) |
|
|
|
}), |
|
|
|
// visualizer({
|
|
|
|
// gzipSize: false,
|
|
|
|
// brotliSize: false,
|
|
|
|
// emitFile: false,
|
|
|
|
// filename: 'test.html', //分析图生成的文件名
|
|
|
|
// open: true
|
|
|
|
// })
|
|
|
|
] |
|
|
|
} |
|
|
|
|