我爱模板网在封装基于element ui的vue插件时,打包报了如下错误:
ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./node_modules/css-loader!./node_modules/element-ui/lib/theme-chalk/index.css 7:177-213
@ ./node_modules/element-ui/lib/theme-chalk/index.css
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/plugin/yx-form-create.vue
@ ./src/plugin/yx-form-create.vue
@ ./src/plugin/yx-form-create.js
ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.woff
Module parse failed: Unexpected character '' (1:4)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./node_modules/css-loader!./node_modules/element-ui/lib/theme-chalk/index.css 7:101-138
@ ./node_modules/element-ui/lib/theme-chalk/index.css
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/plugin/yx-form-create.vue
@ ./src/plugin/yx-form-create.vue
@ ./src/plugin/yx-form-create.js
分析错误描述,应该是字体问题导致的,需要用file-loader进行转换,如果运行没有问题,打包有问题,只需要在webpack.config.js中的module里的rules里添加:
{ test: /\.(png|jpg|gif|eot|woff|ttf|svg|webp|PNG)(\?\S*)?$/, use: ["file-loader"], },