jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

Loading images from inject.js #57

Open dopeboy opened 7 years ago

dopeboy commented 7 years ago

Thanks for creating this extension. It is tremendously helpful.

I am trying to inject a picture into a page from chrome/extension/inject.js. I have installed the file-loader webpack plugin. Then in inject.js, I have the following code in my render():

<img src={require('../assets/img/picture.png')} />

In my manifest file, I have included:

"web_accessible_resources": ["inject.hmtl", "assets/*"]

In my console in Google chrome, I get:

Denying load of chrome-extension://boaecdlopamogbahmoinodmlbnipdpol/js//images/picture.png. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

What am I doing wrong?

jhen0409 commented 7 years ago

@dopeboy could you provide your webpack config?

If you're using file-loader, the image file should extract to js/ folder with {hash}.png as name.