unplugin / unplugin-vue-components

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

Element Plus Resolver not Tree Shaking #305

Open PascalAOMS opened 2 years ago

PascalAOMS commented 2 years ago

Versions:

"element-plus": "^2.0.1",
"vite-ssr": "^0.11.1",

"unplugin-auto-import": "^0.5.11",
"unplugin-icons": "^0.13.0",
"unplugin-vue-components": "^0.17.18",
"vite": "^2.7.13",

Vite Config:

  plugins: [
    Vue(),
    SSR(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [
        ElementPlusResolver({
          ssr: true,
          importStyle: 'sass'
        })
      ]
    })
  ]

When using 1 Element Plus component and running vite-ssr build, all content from Element Plus is put into the JS chunk which reaches over 1 MB. Tree shaking does not take effect.

When I build the SPA version though via vite build, tree shaking does work.

huangbh1024 commented 1 year ago

i also have this problem, how to resolve it

hipi commented 11 months ago

The same question. Now I'm using manual import and also installing unplugin-element-plus for style import.

hipi commented 11 months ago

@antfu need help 🙏