0ahz/vite-plugin-babel-import

import { locale } from 'element-plus' can not work

HongqingCao opened this issue · 1 comments

The default locale of Element Plus is English. If we want to use another language, need to do some i18n configuration。Through the Element Plus website ,we can set

main.js

import { ElButton, locale } from 'element-plus'
import lang from 'element-plus/lib/locale/lang/zh-cn'
import 'dayjs/locale/zh-cn'

locale(lang)

vite.config.js

vitePluginImport([
{
libraryName: 'element-plus',
libraryDirectory: 'es',
style(name) {
return element-plus/lib/theme-chalk/${name}.css;
},
}
])

'element-plus/lib/theme-chalk/locale.css' this file inexistence, so will [vite] Internal server error。

I hope I can improve on this babel,thank you~

0ahz commented

Thanks for the bug report!

fixed by v2.0.3

{
    libraryName: 'element-plus',
    libraryDirectory: 'es',
    style(name) {
      return `element-plus/lib/theme-chalk/${name}.css`;
    },
    ignoreStyles: ['locale'],
},

or

{
    libraryName: 'element-plus',
    libraryDirectory: 'es',
    style(name) {
      if (name === 'locale') return;
      return `element-plus/lib/theme-chalk/${name}.css`;
    },
},