1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { resolve } from 'path'
- import Vue from '@vitejs/plugin-vue'
- // @ts-ignore
- import AutoImport from 'unplugin-auto-import/vite'
- export function createVitePlugins() {
- const root = process.cwd()
- // 路径查找
- function pathResolve(dir: string) {
- return resolve(root, '.', dir)
- }
- return [
- Vue(),
- 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',
- 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')
- }
- }),
- ]
- }
|