无法在vue-cli项目中使用自定义加载器加载模块

问题描述

我有一个项目,其中使用vue-cli设置了Webpack 4.43.0。我正在尝试使用 image-size-loader以在构建时获取图像大小。

为此,在我的一个.vue文件中,我试图使用已在项目中安装的自定义加载器加载模块:

const background = require("image-size!../../../../assets/images/candy.jpg");

在我的项目构建时,它会输出以下错误:

 ERROR  Failed to compile with 1 errors8:47:03 AM

This dependency was not found:

* image-size!../../../../assets/images/candy.jpg in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/vue/guides/tags/hero/TagGroupInvite.vue?vue&type=script&lang=js&

To install it,you can run: npm install --save image-size!../../../../assets/images/candy.jpg

该文件存在,并且js / ts / css文件可以很好地解析。我的设置有什么问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)