Answer the question
In order to leave comments, you need to log in
How to set up Express middleware image loading?
I came across this Express and I'm trying to get my assembly to work with pictures
Here is the devServer.js file
app.use(require('webpack-hot-middleware')(compiler));
app.use('/static', express.static('public'));
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
<Image src="static/public/thumb.jpg" rounded />
Answer the question
In order to leave comments, you need to log in
There is no need for public in the link to the image:
Well, it is advisable to write the paths to folders / files through path:
var path = require('path');
app.use('/static', express.static(path.resolve(__dirname, 'public')));
Since webpack is used for assembly, you can use AssetsPlugin
import thumb from './thumb.jpg';
<Image src={thumb} rounded />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question