Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extract css files specified in 'css' option #22018

Open
2 of 4 tasks
yaquawa opened this issue Jul 7, 2023 · 6 comments
Open
2 of 4 tasks

Allow extract css files specified in 'css' option #22018

yaquawa opened this issue Jul 7, 2023 · 6 comments

Comments

@yaquawa
Copy link

yaquawa commented Jul 7, 2023

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

@rikyotei
Copy link

rikyotei commented Jul 8, 2023

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

@yaquawa
Copy link
Author

yaquawa commented Jul 9, 2023

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

@rikyotei
Copy link

rikyotei commented Jul 9, 2023

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

Downgrade to 3.5.3

@dargmuesli
Copy link
Member

Related: vitejs/vite#11864

@rikyotei
Copy link

rikyotei commented Sep 9, 2023

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

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

@danielroe
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants