Replies: 1 comment
-
Yes, though it requires some workarounds. Put it in your public folder, or, if it needs to be processed by Vite, make it an unlisted CSS entrypoint. Then in your HTML pages, use a reference like In your content script, you'll have to add the CSS to the page manually by creating a async onMount(uiContainer, shadow) {
const url = browser.runtime.getURL('/<path-to-style>.css');
const myStyles = document.createElement('style');
const myStyle.textContent = await (await fetch(url)).text();
shadow.querySelector('head').append(myStyles);
// The rest of your code
} There are several reasons why fetching the CSS text content is better than using a link with a URL, but you could try that if you want. Mainly that the CSS needs to be loaded before the UI is mounted. Otherwise you see flashing styles and layout shifts. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
in my extension, I use the same css file
@/assets/style.css
in all my page entrypoints (same link tag in the index.html for option page, pop-up page, etc.):When building the extension, the style.css lands in the
assets
folder and the css file is used by all pages. So far, so good.However, I use the same css file also in an injection script with shadowRootUI like this:
This then results in an
injection.js
and aninjection.css
file in thecontent-scripts
folder.So the style.css is actually contained twice in my extension.
Isn't there a possibility to reuse the generated css file in the
assets
folder also for the injection script?Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions