ElementUI / babel-plugin-component

Modular element-ui build plugin for babel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-component 按需引入报错,没有找到 base.css 文件

Jennifer249 opened this issue · comments

自己写了个仿 element-ui 的小 demo,去实现按需引入,可是在测试项目里使用 babel-plugin-component,遇到报错

image

下面是我的相关文件:
测试项目相关:

import { Button } from 't-element-ui'
Vue.use(Button)
# For babel6
npm i babel-plugin-component@0 -D

package.json
image

.babelrc:
image

仿 element-ui demo:

image

以上会报错。但按照文档说明来看,应该没有 base.css 文件就不会自动生成引入 base.css
image

解决办法是,手动增加 base.css 文件。我给了个空文件。最后解决了报错。
image

所以问题是,demo 里没有 base.css,却会有引用报错。

自问自答下,好好看文档。。
image

如果配置了 styleLibraryName,base.css 是必须的。
如果不想 base.css 必须,那么配置 styleLibrary.name,可跑通。
image