-
-
Notifications
You must be signed in to change notification settings - Fork 428
Description
What happened?
Given a content script loaded like so:
import type { PlasmoCSConfig } from "plasmo";
import scriptUrl from "url:~/contents/injectSomething.js";
export const config: PlasmoCSConfig = {
matches: ["http://localhost:3000/*", "https://mydomain.com/*"],
};
That generates a manifest with:
{
"web_accessible_resources": [
{
"resources": ["src/injectSomething.js"],
"matches": ["http://localhost:3000/*", "https://mydomain.com/*"]
},
{
"matches": [
"http://localhost:3000/*",
"https://mydomain.com/*"
],
"resources": ["injectSomething.d5bf3908.js"]
}
],
"content_scripts": [
{
"matches": ["<all_url>"],
"js": ["injectSomething.d5bf3908.js"],
"css": []
},
]
}
It seems that co-locating assets together with modules in the contents/
confuses the bundler and creates content_scripts
entries.
Unsure if it's supposed to be like that, but it was quite a WTF moment for me an wasted a lot of time debugging. Please note that there is no config present anywhere for this .js
file, so it silently defaults to <all_url>
which would affect the extension's store submission. I honestly didn't even know that .js
files are supported as content scripts? - I thought only tsx modules containing PlasmoCSConfig are allowed (!?)
My recommendation: if an asset is being handled by the url:
handler, put it in a exclusionsList
of sorts, and emit a warning or exclude it from content scripts when they're being generated.
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Chrome
Relevant log output
(OPTIONAL) Contribution
- I would like to fix this BUG via a PR
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate problems.