unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.68k stars 342 forks source link

Some ElementUI components are missing or not working when previewing after build. #680

Open shihongxins opened 11 months ago

shihongxins commented 11 months ago

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: development

previewing

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

wangjian27 commented 10 months ago

遇到相同的问题 image

undefine4080 commented 9 months ago

遇到相同的问题,翻了翻一休,没有看到解决的 Snipaste_2023-10-16_16-25-12