Closed ziedHamdi closed 1 year ago
Fix the content type in your endpoint, text/css instead of text/html, either remove %sveltekit.assets%
in app.html or use the
Digging a little bit more, I created an html page with a link to the css file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Blue</title>
<link rel='stylesheet' type="text/css" href='http://localhost:5174/css/default.css'>
</head>
<body>
<div>Hello everybody</div>
</body>
</html>
Then I opened the file in the browser, in dev tools, when I go to the css file, and modify it, suddenly all styles are applied correctly. I don't understand what can be the cause for that. But I suspect the endpoint not to close the connection, letting the browser hanging waiting for more bytes...???
text/css
Just saw your answer! thanks a lot
Describe the bug
I'm really confused because I don't know if this is related to svelte endpoints or to how styles are loaded. This is my issue:
I'm trying to load a Css file from the server (to allow users to edit templates). All I'm doing is to to create an endpoint that returns a css content.
NOTE: I checked that the css file is correctly loaded, and checked that the style syntax is valid. I just can't find any explanation on why it doesn't work
like follows:
and I load that endpoint in app.html
<link rel='stylesheet' type="text/css" href='%sveltekit.assets%/css/default.css'>
Reproduction
https://github.com/ziedHamdi/svelteServerCss/tree/master
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
The reason why I'm trying to do this is because it's impossible to dynamically add css classes to a page. There's an SF question about the issue here: https://stackoverflow.com/questions/76091194/using-dynamic-css-class-loading-in-sveltekit
p.s: As I saw the answer to another issue I tried to insert the style through
That also didn't work