-
Notifications
You must be signed in to change notification settings - Fork 388
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
Reduce Tailwind CSS bundle size for unused components #877
Comments
Related to #802 do you want separate issues on reducing the unused colors (this could be an option parameter, even) and reducing bundle size for unused components? |
Removing unused colors is already done through Smart safelisting and I already answered here #802 (comment) on how to select only desired colors, not sure why you want to create another issue. |
I read the docs and that's what |
Sorry to jump in, but simply adding |
It is related to this issue, the whole config is taken into account by Tailwind: https://github.com/nuxt/ui/blob/dev/src/runtime/ui.config.ts |
Is that ui.config file now available for Tailwind to do it's magic? Or does it do something more in nuxt/ui code? I am trying to scope the fix here. |
Hello, This is pretty serious affecting performance. @Atinux can this pushed forward please? Thanks! |
The build size is huge when using Static Site. Weirdly, NuxtUI is adding the tailwind styles inside a <style> tag inside all .HTML files. Is something broken or am I missing something? |
@benjamincanac any timeline for this? |
Hey! We're researching into this and hoping to come up with a breakthrough soon. 😄 |
@sigmaxf I think this is more of nuxt's features. Try to fiddle with https://nuxt.com/docs/guide/going-further/experimental-features#inlinessrstyles |
There should be a workaround available for this now, if someone would like to report back on this please. See "Tailwind CSS bundle" section on release notes for https://github.com/nuxt/ui/releases/tag/v2.11.0. |
@ineshbose thanks! your help is highly appreciated! I've tried excluding everything (on an empty project), and went down from 253kb to 185kb. Just to understand the issue, is it not possible to load nuxt ui before cssnano? Here's what I excluded, if it helps anyone:
|
@ronenteva have you limited the amount of color entries in the final outcome? It has an impact, too. See #889 |
@jrutila thanks! it's now down to 102kb
|
cssnano should include all the styles from NuxtUI after build. |
Let me add another solution to this problem: This should remove unused styles from your page, but few things to note - load this module BEFORE |
@ineshbose Will the critters solution work for |
It needs SSR enabled. Rest, you can exclude files from Tailwind content (a for-loop or even a Nuxt module would be quite elegant) for now. |
@benjamincanac @ineshbose |
Hey! Thanks for pinging - this issue is still in mind. Unfortunately content detection is a tricky part of Tailwind JIT and a component library based on Tailwind would have such limitations. We'll have to come up with some ground breaking stuff to have dynamic content based on import (contributions welcome) which all of TW community would benefit from, but till then we have a workaround available. |
Do you mind sharing an example of how to use critters to remove the unused styles? Another workaround is to use nuxt-purgecss and safelist all classes in the components in use. |
@ronenteva Excluding all of the config files did not do the trick? |
@benjamincanac I stopped using it at some point but I honestly can't remember what wasn't working. Update: |
If dark mode is not needed, you can save another 30k by setting: nuxt.config.js
tailwind.config.js
|
Providing a workaround:
significantly drop from ~700kb to ~160kb (the 160kb is because another ui library I use. |
No description provided.
The text was updated successfully, but these errors were encountered: