chrome-extension-boilerplate-react icon indicating copy to clipboard operation
chrome-extension-boilerplate-react copied to clipboard

Importing images into the content script

Open dpw1 opened this issue 1 year ago • 2 comments

Hello,

Firstly thank you very much for the excellent work! Is there anyway I can import images into my content script? I have tried it like this:

import logo from '../../../assets/img/icon-128.png';

But it doesn't work. Any help is greatly appreciated. Thanks!

dpw1 avatar Aug 20 '23 10:08 dpw1

Did some soul searching and came up with this.

import icon from '../../../assets/test.jpg';
const container = document.createElement("div")
container.className = "charlie";
container.style.backgroundImage = `url('${chrome.runtime.getURL(icon)}')`;

But running into the issue with web_accessible_resources

thatBrian avatar Mar 30 '24 01:03 thatBrian

Fixed the web_accessible_resource issue by updating the manifest.json file. https://github.com/GoogleChrome/developer.chrome.com/issues/544#issuecomment-806260538

thatBrian avatar Mar 30 '24 01:03 thatBrian