If you are still looking for an option to import an external css please try this.. its a bit experimental but it works.
-- script--
import {onMount} from 'svelte'; let rootElement;
function loadExternalCss(parent, file) { let element = document.createElement("link"); element.setAttribute("rel", "stylesheet"); element.setAttribute("type", "text/css") element.setAttribute("href", file) parent.appendChild(element) }
onMount(() => { loadExternalCss(rootElement, './yourfolder/yourfile.css') })
--/script--
in the html markup add this to the root element.
bind:this={rootElement}
this way you can even have css variables syntax support and also it works in svelte custom elements .
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you are still looking for an option to import an external css please try this..
its a bit experimental but it works.
-- script--
import {onMount} from 'svelte';
let rootElement;
function loadExternalCss(parent, file) {
let element = document.createElement("link");
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css")
element.setAttribute("href", file)
parent.appendChild(element)
}
onMount(() => {
loadExternalCss(rootElement, './yourfolder/yourfile.css')
})
--/script--
in the html markup add this to the root element.
bind:this={rootElement}
this way you can even have css variables syntax support and also it works in svelte custom elements .