Open upokusaev opened 6 months ago
Hey, @upokusaev , Hope this will solve your problem-
import raw from 'url:~/contents/CustomPopup.tsx';
chrome.action.onClicked.addListener(async (tab) => {
try {
await sendToContentScript({
name: "click"
})
} catch (e) {
// The error occurs on pages that were opened in the browser before the extension was installed
chrome.scripting.executeScript(
{ target: { tabId: tab.id }, files: [raw] },
() => {
setTimeout(() => {
sendToContentScript({
name: "click"
})
}, 500)
}
)
}
})
Unfortunately, no.
url
directive - does not work.
Error:
Unchecked runtime.lastError: Could not load file: 'chrome-extension://bke...cde/static/background/../../CalendarPopup.828a0e9c.js'.
plasmo doesn't seem to have this feature, it uses Parcel as a packaging library. we can change the packaging configuration to achieve this.
.parcelrc
{ "extends": ["@parcel/config-default","@plasmohq/parcel-config"], "namers": [ "@plasmohq/parcel-namer-manifest","parcel-namer-rewrite" ] }
package.json
"parcel-namer-rewrite": { "hashing": "never" },
What is the example you wish to see?
I'd like to see how I can embed the content script into a page manually
Is there any context that might help us understand?
I have this structure
In the
intex.ts
file I use the following code:Instead of
CustomPopup.hash.js
, I want to use the correct name of the final script. Or I want to disable hashes for prod builds, if the file name is impossible to know.I tried using
url:
andraw:
directives but it didn't help, because of them a second script is created which doesn't work the same way as the first one. Probably because the scripts in thecontents
folder are handled in a special way.P.S. Now I have to use a workaround in the form of a .sh script that is executed after the build:
Code of Conduct