Hi,
I’m trying to understand how webpack is working. For this I created a very simple example:
webpack.config.js
const path = require('path');
module.exports = {
entry: ['./src/index.js'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
devtool: 'source-map',
};
index.html
<body>
<div>
<img src="../src/images/lion.png" alt="">
</div>
<script src="./bundle.js"></script>
</body>
As you can see the index.html is inside the dist folder. If I open the index.html in browser, it shows the images. But if I run the dev-server, it starts the browser, shows the index.html but cannot find the image. And the console shows this error:
Failed to load resource: The server responded with a status of 404. lion.png
Does any one know why webpack cannot show the image?