You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@import"@fontsource/inter/400.css";
/* Other stuff... */
I do the same in the extension popup and it works perfectly there. However, in the content script, it results in the extension attempting to load the resources from the visited website, and you obviously get a 404:
body {
background-image:url('chrome-extension://__MSG_@@extension_id__/background.png');
}
And indeed, if I build my extension, go to the generated CSS, and manually prepend chrome-extension://__MSG_@@extension_id__, everything starts working. In other words, this:
In addition, chrome-extension://__MSG_@@extension_id__ appears to resolve correctly in popup scripts as well. If I add it in the same CSS file that is loaded both in the popup and the content script — it works in both places.
Maybe one possible solution is to just always prepend chrome-extension://__MSG_@@extension_id__, regardless of the script's location (popup or content)?
It prepends the string to the output asset URLs and works perfectly. Still, in my opinion, it'd be great if CRXJS uses this internally, so end-users don't have to face this issue.
Build tool
Vite
Where do you see the problem?
Describe the bug
I have a simple content script that imports CSS with fonts:
manifest.json:
content.tsx:
index.css:
I do the same in the extension popup and it works perfectly there. However, in the content script, it results in the extension attempting to load the resources from the visited website, and you obviously get a 404:
This problem has been raised in Stack Overflow and the solution is to use a special string in the CSS resource path, as explained in the Chrome docs:
And indeed, if I build my extension, go to the generated CSS, and manually prepend
chrome-extension://__MSG_@@extension_id__
, everything starts working. In other words, this:…has to turn to this:
Reproduction
Create a content script and try to import any CSS asset.
Logs
No response
System Info
The text was updated successfully, but these errors were encountered: