解决方案有三种:
1.通过import方式引入图片;
例:import imgUrl from 'path/to/..png';
2.通过CommonJS方式引入;
var imgUrl = requrie('path/to/..png');
3.通过html-loader插件方式来解决;
步骤:一、npm install -d html-loader;
二、把下面代码放入webpack.config.js配置里:
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: ['img:src', 'img:data-src', 'audio:src'],
minimize:true
}
}
}