N
Nuxt3y ago
Joaquín

importing raw css with ?inline

I want to inline some critical css styles into a head style (via useHead in all layouts) using import appCss from '../app.css?inline, but them, I get those styles duplicated: running dev server I can see this style being added twice (link preload + link stylesheet) and also the style entry, is there a way to prevent this (maybe Vite problem)?
No description
18 Replies
Joaquín
JoaquínOP3y ago
the style is just below the theme-color meta entry https://github.com/vitejs/vite/pull/10762#issuecomment-1301860548 adding &used is even worst, it is added 4 times; using only ?used only adds the stylesheet link (no preload) since I have only 1 layout I'll copy the content
danielroe
danielroe3y ago
What happens if you try disabling experimental.renderInlineStyles?
harlan
harlan3y ago
could be a hydration issue if something is happening differently between client + server, you could use a key on that style entry to test that key: 'app-css'
danielroe
danielroe3y ago
Good suggestion. I think ?inline will result in an empty string on server build (but will result in inlining it if you have renderInlineStyles turned on), which is why &used is needed to get the string (but will still also inline it).
Joaquín
JoaquínOP3y ago
I'm testing it rn, I added an id not a key @danielroe there is no such entry, do you mean inlineSSRStyles? wow writeEarlyHints 💯
danielroe
danielroe3y ago
that'd be the one.
Joaquín
JoaquínOP3y ago
disabling inlineSSRStyles using only ?inline both links on the head adding id and key to the style... wait...
Joaquín
JoaquínOP3y ago
No description
Joaquín
JoaquínOP3y ago
the same result adding id and key to the script using import appCss from '../app.css' doesn't work either
Joaquín
JoaquínOP3y ago
No description
danielroe
danielroe3y ago
you'll really need to build this to see.
Joaquín
JoaquínOP3y ago
ok
danielroe
danielroe3y ago
we don't inline styles in dev mode at all, but we do automatically inline critical styles in prod (that is, that are used in a vue SFC) so it may be you don't even need to do this
Joaquín
JoaquínOP3y ago
I know, the problem, styles being duplicated: is there a way to hint some order? it seems the styles in the pages will go first, then styles from the imports in the layout
danielroe
danielroe3y ago
Interesting. And just to confirm you're on 3.0.0?
Joaquín
JoaquínOP3y ago
No description
Joaquín
JoaquínOP3y ago
No description
Joaquín
JoaquínOP3y ago
hey @danielroe sorry to bother you, is there a way to avoid doing this hacks https://discord.com/channels/473401852243869706/1043560786364223603 ?
Want results from more Discord servers?
Add your server