nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Allow extract css files specified in 'css' option

Open yaquawa opened this issue 2 years ago • 6 comments

Describe the feature

Currently, the CSS files specified in the css option are injected using JavaScript. It would be beneficial if these CSS files could be extracted and utilized through the link element instead.

The reason behind this request is that my CSS file is quite large, and by not using the element, the styles are not displayed immediately during the page load.

I understand that I can use the app.head.link option, but unfortunately, this doesn't include the compilation of SCSS files, and I am unable to benefit from assets compiling.

Additional information

  • [ ] Would you be willing to help implement this feature?
  • [ ] Could this feature be implemented as a module?

Final checks

yaquawa avatar Jul 07 '23 11:07 yaquawa

Totally agree, Inline CSS should not be the only option.

rikyotei avatar Jul 08 '23 08:07 rikyotei

Is there a temporary workaround available for this issue in the meantime?

yaquawa avatar Jul 09 '23 11:07 yaquawa

Is there a temporary workaround available for this issue in the meantime?

Downgrade to 3.5.3

rikyotei avatar Jul 09 '23 14:07 rikyotei

Related: https://github.com/vitejs/vite/pull/11864

dargmuesli avatar Aug 30 '23 23:08 dargmuesli

Is there a temporary workaround available for this issue in the meantime?

https://nuxt.com/docs/guide/going-further/experimental-features#inlinessrstyles

rikyotei avatar Sep 09 '23 00:09 rikyotei

Would you try this?

export default defineNuxtConfig({
  features: {
    inlineStyles: id => !id?.includes('entry')
  }
})

This should avoid inlining the entry CSS (i.e. global CSS) but still inline any individual CSS from components.

danielroe avatar Feb 12 '24 14:02 danielroe