Add auto import react and antd

This commit is contained in:
2023-09-01 22:39:19 +08:00
parent 7cedf04d92
commit e71dec551e
12 changed files with 526 additions and 78 deletions

View File

@@ -6,6 +6,7 @@ import Icons from 'unplugin-icons/vite'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
import IconsResolver from 'unplugin-icons/resolver'
import AutoImport from 'unplugin-auto-import/vite'
import { AntDesignResolver } from './build/resolvers/antd'
// https://vitejs.dev/config/
export default defineConfig({
@@ -13,13 +14,54 @@ export default defineConfig({
react(),
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
AutoImport({
// targets to transform
include: [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.md$/ // .md
],
// global imports to register
imports: [
'react',
'react-router',
'react-router-dom',
{
'react-router': ['useMatches', 'RouterProvider'],
'react-router-dom': ['createBrowserRouter'],
antd: ['message']
},
{
from: 'react-router',
imports: ['RouteObject'],
type: true
}
],
// Filepath to generate corresponding .d.ts file.
// Defaults to './auto-imports.d.ts' when `typescript` is installed locally.
// Set `false` to disable.
dts: './auto-imports.d.ts',
// Custom resolvers, compatible with `unplugin-vue-components`
// see https://github.com/antfu/unplugin-auto-import/pull/23/
resolvers: [
IconsResolver({
prefix: 'icon',
extension: 'jsx',
customCollections: ['framework']
}),
AntDesignResolver({
resolveIcons: true
})
]
],
// Generate corresponding .eslintrc-auto-import.json file.
// eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
eslintrc: {
enabled: true, // Default `false`
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
}
}) as PluginOption,
Icons({
compiler: 'jsx',