DEV Community

loading...

Discussion on: use create-react-app to develop Chrome extensions

Collapse
miso01 profile image
Michal Švec

Really amazing article, good work :) ! On the internet are few solutions for react extension but almost every of them have some drawbacks. This seems to me be the best solution and the most explained solution.

I have one question for you. How can I include content script into manifest ? I've tried it to put it to the same folder as background.js and when I try to load it I get an error which saying that unable to load content.js.

"content_scripts": [
{
"matches": [""],
"js": [
"content.js"
]
}
]

I found one way which works, but it's quite complicated, you know... It's needed to eject react and remove some configs which hashing the name of file after every build. Then I loaded file from static folder....

"content_scripts": [
{
"matches": [""],
"js": [
"/static/js/2.chunk.js",
"/static/js/main.chunk.js",
"/static/js/runtime-main.js"
]
}
]

I'm quite confused why background.js can be loaded from same folder and content.js can't.

Collapse
jamalx31 profile image
Jamal Mashal Author

Hi Michel,
I think you can do that by modifying config-overrides.js to copy your js file the same way I copy background.js