Reputation: 29
I want to use images using url not by using import statement.
Expected way: <img src={"/images/logo.png"} alt="logo" className={classes.logo} />
Not Expected: import logo from '../../../public/images/logo.png'
following is my application structure, Please let me know what loader or configuration or any better way is present for dev & prod environment?
Here is my webpack configuration for development.
Thanks in advance :)
Upvotes: 1
Views: 878
Reputation: 98
Try this
<img src={process.env.PUBLIC_URL + '/yourPath.jpg'} />
Or this should also work
<img src={window.location.origin + '/yourPath.jpg'} />
Upvotes: 0