From a9b2b816f82020a2f91cdab59d094d6236c2aeff Mon Sep 17 00:00:00 2001 From: Nex Zhu <4370605+NexZhu@users.noreply.github.com> Date: Mon, 27 Dec 2021 19:23:47 +0800 Subject: [PATCH] feat: add unplugin-vue-components --- .fes.js | 10 +++++++ .gitignore | 1 + package-lock.json | 58 ++++++++++++++++++++++++++++++++++++++- package.json | 3 +- src/types/components.d.ts | 12 ++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/types/components.d.ts diff --git a/.fes.js b/.fes.js index 485e37b..44fe372 100644 --- a/.fes.js +++ b/.fes.js @@ -2,6 +2,7 @@ import ESLintPlugin from 'eslint-webpack-plugin' import StylelintPlugin from 'stylelint-webpack-plugin' import AutoImportPlugin from 'unplugin-auto-import/webpack' +import VueComponentsPlugin from 'unplugin-vue-components/webpack' export default { publicPath: './', @@ -61,5 +62,14 @@ export default { ], }), ) + config.plugin('vue-components').use( + VueComponentsPlugin({ + dts: './src/types/components.d.ts', + include: [ + /src\/.+\.vue$/, + /src\/.+\.vue\?vue/, // .vue + ], + }), + ) }, } diff --git a/.gitignore b/.gitignore index 19d5443..f59c053 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ ### Custom ### src/.fes +src/.fes-production ### Node ### # Logs diff --git a/package-lock.json b/package-lock.json index 2e0bae4..6b54ca7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,8 @@ "stylelint-config-recommended-vue": "^1.1.0", "stylelint-webpack-plugin": "^3.1.0", "typescript": "^4.5.4", - "unplugin-auto-import": "^0.5.5" + "unplugin-auto-import": "^0.5.5", + "unplugin-vue-components": "^0.17.11" } }, "node_modules/@ant-design/colors": { @@ -12861,6 +12862,43 @@ } } }, + "node_modules/unplugin-vue-components": { + "version": "0.17.11", + "resolved": "https://registry.npmjs.org/unplugin-vue-components/-/unplugin-vue-components-0.17.11.tgz", + "integrity": "sha512-u5MQ0TbikszRelCt6EA/HskGtGkGLDxi7tQ4/4tcEPWkH3yXSZRJCOeLF5MSdxN1SiGjaJ0I9zeHjoZFC3FvRw==", + "dev": true, + "dependencies": { + "@antfu/utils": "^0.3.0", + "@rollup/pluginutils": "^4.1.1", + "chokidar": "^3.5.2", + "debug": "^4.3.2", + "fast-glob": "^3.2.7", + "local-pkg": "^0.4.0", + "magic-string": "^0.25.7", + "minimatch": "^3.0.4", + "resolve": "^1.20.0", + "unplugin": "^0.2.21" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@babel/parser": "^7.15.8", + "@babel/traverse": "^7.15.4", + "vue": "2 || 3" + }, + "peerDependenciesMeta": { + "@babel/parser": { + "optional": true + }, + "@babel/traverse": { + "optional": true + } + } + }, "node_modules/unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -23426,6 +23464,24 @@ "unplugin": "^0.2.21" } }, + "unplugin-vue-components": { + "version": "0.17.11", + "resolved": "https://registry.npmjs.org/unplugin-vue-components/-/unplugin-vue-components-0.17.11.tgz", + "integrity": "sha512-u5MQ0TbikszRelCt6EA/HskGtGkGLDxi7tQ4/4tcEPWkH3yXSZRJCOeLF5MSdxN1SiGjaJ0I9zeHjoZFC3FvRw==", + "dev": true, + "requires": { + "@antfu/utils": "^0.3.0", + "@rollup/pluginutils": "^4.1.1", + "chokidar": "^3.5.2", + "debug": "^4.3.2", + "fast-glob": "^3.2.7", + "local-pkg": "^0.4.0", + "magic-string": "^0.25.7", + "minimatch": "^3.0.4", + "resolve": "^1.20.0", + "unplugin": "^0.2.21" + } + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", diff --git a/package.json b/package.json index 57cd298..e087955 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "stylelint-config-recommended-vue": "^1.1.0", "stylelint-webpack-plugin": "^3.1.0", "typescript": "^4.5.4", - "unplugin-auto-import": "^0.5.5" + "unplugin-auto-import": "^0.5.5", + "unplugin-vue-components": "^0.17.11" }, "dependencies": { "@fesjs/fes": "^2.0.11", diff --git a/src/types/components.d.ts b/src/types/components.d.ts new file mode 100644 index 0000000..8536aae --- /dev/null +++ b/src/types/components.d.ts @@ -0,0 +1,12 @@ +// generated by unplugin-vue-components +// We suggest you to commit this file into source control +// Read more: https://github.com/vuejs/vue-next/pull/3399 + +declare module 'vue' { + export interface GlobalComponents { + PageLoading: typeof import('./../components/PageLoading.vue')['default'] + UserCenter: typeof import('./../components/UserCenter.vue')['default'] + } +} + +export {}