ERROR in ./src/img/7.jpg 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
解决办法:
npm i url-loader@4.1.1 file-loader@6.2.0 -D
webpack.config.js 的 module rules数组中 增加
module: { // 所有第三方文件模块的匹配规则
rules:[ // 文件后缀名的匹配规则
{test:/\.jpg|png|gif$/,use:'url-loader?limit=22229'}
]
}
limit 指定图片大小 ,图片小于等于 limit 22229字节 的时候才会转成 base64
本文介绍了如何修复Webpack在处理图片时遇到的'Unexpected character'错误,通过安装url-loader和file-loader,并调整webpack.config.js中的规则,限制图片大小以避免编码问题。
7567

被折叠的 条评论
为什么被折叠?



