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