unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

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

Open shihongxins opened this issue 1 year ago • 2 comments

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

  • [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.

shihongxins avatar Aug 17 '23 05:08 shihongxins

遇到相同的问题 image

wangjian27 avatar Sep 12 '23 07:09 wangjian27

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

undefine4080 avatar Oct 16 '23 08:10 undefine4080