From bb04bb0961012226f8bb0ea9ebf2c1af621d6205 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Thu, 8 Aug 2024 16:07:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E5=AF=BC=E5=85=A5ant?= =?UTF-8?q?d=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ apps/web-antd/package.json | 3 ++- apps/web-antd/tsconfig.json | 2 +- apps/web-antd/vite.config.mts | 14 ++++++++++++++ pnpm-lock.yaml | 36 +++++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3787c523..174207d3 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ vite.config.ts.* *.njsproj *.sln *.sw? +# 排除自动生成的类型文件 +apps/web-antd/types/components.d.ts diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index a4e0ea03..0f17ecee 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "@types/crypto-js": "^4.2.2", - "@types/lodash-es": "^4.17.12" + "@types/lodash-es": "^4.17.12", + "unplugin-vue-components": "^0.27.3" } } diff --git a/apps/web-antd/tsconfig.json b/apps/web-antd/tsconfig.json index 02c287fe..9d43c929 100644 --- a/apps/web-antd/tsconfig.json +++ b/apps/web-antd/tsconfig.json @@ -8,5 +8,5 @@ } }, "references": [{ "path": "./tsconfig.node.json" }], - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "types/**/*.d.ts"] } diff --git a/apps/web-antd/vite.config.mts b/apps/web-antd/vite.config.mts index fe839770..8423c3dc 100644 --- a/apps/web-antd/vite.config.mts +++ b/apps/web-antd/vite.config.mts @@ -1,9 +1,23 @@ import { defineConfig } from '@vben/vite-config'; +import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; +import Components from 'unplugin-vue-components/vite'; + export default defineConfig(async () => { return { application: {}, vite: { + plugins: [ + Components({ + dirs: [], // 默认会导入src/components目录下所有组件 不需要 + dts: './types/components.d.ts', // 输出类型文件 + resolvers: [ + AntDesignVueResolver({ + importStyle: false, // css in js + }), + ], + }), + ], server: { proxy: { '/api': { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e13dde85..bf14982e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -191,6 +191,9 @@ importers: '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 + unplugin-vue-components: + specifier: ^0.27.3 + version: 0.27.3(@babel/parser@7.25.3)(rollup@4.20.0)(vue@3.4.36(typescript@5.5.4)) apps/web-ele: dependencies: @@ -3306,6 +3309,7 @@ packages: '@ls-lint/ls-lint@2.2.3': resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==} + cpu: [x64, arm64, s390x] os: [darwin, linux, win32] hasBin: true @@ -9021,6 +9025,19 @@ packages: resolution: {integrity: sha512-jByUGY3FG2B8RJKFryqxx4eNtSTj+Hjlo8edcOdJymewndDQjThZ1pRUQHRjQsbKhTV2jEctJV7t7RJ405UL4g==} engines: {node: '>=14.19.0'} + unplugin-vue-components@0.27.3: + resolution: {integrity: sha512-5wg7lbdg5ZcrAQNzyYK+6gcg/DG8K6rO+f5YeuvqGHs/PhpapBvpA4O/0ex/pFthE5WgRk43iWuRZEMLVsdz4Q==} + engines: {node: '>=14'} + peerDependencies: + '@babel/parser': ^7.15.8 + '@nuxt/kit': ^3.2.2 + vue: ^3.4.36 + peerDependenciesMeta: + '@babel/parser': + optional: true + '@nuxt/kit': + optional: true + unplugin@1.12.0: resolution: {integrity: sha512-KeczzHl2sATPQUx1gzo+EnUkmN4VmGBYRRVOZSGvGITE9rGHRDGqft6ONceP3vgXcyJ2XjX5axG5jMWUwNCYLw==} engines: {node: '>=14.0.0'} @@ -18252,6 +18269,25 @@ snapshots: transitivePeerDependencies: - rollup + unplugin-vue-components@0.27.3(@babel/parser@7.25.3)(rollup@4.20.0)(vue@3.4.36(typescript@5.5.4)): + dependencies: + '@antfu/utils': 0.7.10 + '@rollup/pluginutils': 5.1.0(rollup@4.20.0) + chokidar: 3.6.0 + debug: 4.3.6 + fast-glob: 3.3.2 + local-pkg: 0.5.0 + magic-string: 0.30.11 + minimatch: 9.0.5 + mlly: 1.7.1 + unplugin: 1.12.0 + vue: 3.4.36(typescript@5.5.4) + optionalDependencies: + '@babel/parser': 7.25.3 + transitivePeerDependencies: + - rollup + - supports-color + unplugin@1.12.0: dependencies: acorn: 8.12.1