Reputation: 436
I'm creating a simple SharePoint webpart using SPFX, I wanna reference images in the solution. I used this method:
require("@microsoft/loader-set-webpack-public-path!");
<img src="${require<string>('../../assets/logo.jpg')}" alt="My Company" />
But it doesn't work.
How to achieve that ?
Upvotes: 1
Views: 7031
Reputation: 5493
Sample test demo:
No framework:
<img src="${require<string>('../../download.jpg')}" alt="My Company" />
React framework:
<img src={require('../../assets/panda.jpg')} alt="test" />
Upvotes: 8