unplugin-vue-components
unplugin-vue-components copied to clipboard
Some ElementUI components are missing or not working when previewing after build.
Describe the bug
I created a project with vite and vue2 by create-vue, then I use this and unplugin-auto-import tools to import element-ui components. It's ok in development stage. But some element-ui components are missing or not working when previewing after build.
this is my vite config:
// vite.config.js
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import legacy from "@vitejs/plugin-legacy";
import vue2 from "@vitejs/plugin-vue2";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementUiResolver } from "unplugin-vue-components/resolvers";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue2(),
legacy({
targets: ["ie >= 11"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
}),
AutoImport({
resolvers: [ElementUiResolver()],
}),
Components({
resolvers: [ElementUiResolver()],
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
});
these are snaped images:
Reproduction
https://github.com/shihongxins/vite-vue2-element-ui
System Info
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
Memory: 7.30 GB / 15.85 GB
Binaries:
Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
pnpm: 7.18.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Spartan (44.19041.1.0), Chromium (115.0.1901.203)
Internet Explorer: 11.0.19041.1
Used Package Manager
npm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guide.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- [X] The provided reproduction is a minimal reproducible of the bug.
遇到相同的问题
遇到相同的问题,翻了翻一休,没有看到解决的