I following this post of how to setup webpack and url-loader can successfully encode the url but the image path is broken and image does not show up. I am not sure what I am doing wrong. Am I missing something obvious? Thanks for any help you can give.
webpack.config
{
test: /\.(gif|png|jp(e*)g|svg)$/,
use: [{
loader: 'url-loader',
options: {
limit: 1000000,
name: 'images/[hash]-[name].[ext]',
}
}]
}
index.js
import homeIcon from '../images/image-file.png';
var homeImg = document.getElementById('home');
homeImg.src = homeIcon;
index.html
File Structure
src
js
index.js
images
image-file.png