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

Treeshaking fails at CSS #342

Open
bengineer19 opened this issue Jun 9, 2020 · 13 comments
Open

Treeshaking fails at CSS #342

bengineer19 opened this issue Jun 9, 2020 · 13 comments

Comments

@bengineer19
Copy link
Contributor

Module version
1.11.0

Describe the bug
Even with treeshaking enabled, Vuetify includes a large amount of unneeded CSS when the nuxt project is built.

To Reproduce
Build any nuxt-vuetify project, open Chrome devtools, go to Sources, open Coverage tab, observe how much CSS (and JS) is unused.

By default this is included in vendors.js as main.sass, but setting extractCSS: true in webpack config pulls out the CSS into a separate file, where the inefficiency can be clearly viewed. I have included a pic of one of my projects in the screenshots section below. The CSS which is inlined in HTML files also has plenty of waste.

This occurs for the quickstart create-nuxt-app default page, and the default code sandbox https://codesandbox.io/s/nuxtjs-vuetify-v0k7i.

Expected behavior
Would like only the necessary CSS to be shipped to the browser.

Screenshots
image

@mathe42
Copy link

mathe42 commented Jun 9, 2020

You are in Development mode? Try it in production => optimized build.

@bengineer19
Copy link
Contributor Author

No, this is after running nuxt build then nuxt start. NODE_ENV is set to production and nuxt build logs "production build".

@mathe42
Copy link

mathe42 commented Jun 9, 2020

OK strange...

@bengineer19
Copy link
Contributor Author

Here is the coverage of the default app created from the quickstart, running after $ npm run build && npm run start.
In nuxt.config.js I set treeShake: true and extractCSS: true

To be clear, this appears to suggest that every project using this module ships 283kB of CSS to the browser, of which over 90% is unused for most applications.

image

@bengineer19 bengineer19 changed the title Remove unused CSS Treeshaking fails at CSS Jun 11, 2020
@yohane55
Copy link

yohane55 commented Jun 13, 2020

when I set extractCSS: true, it usually increases the bundle size. try building without it.

@little3201
Copy link

does it occurred when use vuetify only with vue?

@dor272
Copy link

dor272 commented Aug 23, 2020

Having the same issue. I use SSG and I get FOUC probably because of the time it takes to load the entire css of vuetify instead of very little that is actually used.

any way around it?

@Guebbit
Copy link

Guebbit commented Nov 2, 2020

Interested and following. I'd love to include some of vuetify plugins and optimize everything

@ReindDooyeweerd
Copy link

ReindDooyeweerd commented Nov 12, 2020

Same here, just made a fresh project, cleaned out all the default stuff inside index.vue so nothing of Vuetify should be loaded, did a build and it serves a 314KiB css file with all the Vuetify css in it.

Vuetify related stuff inside my nuxtjs.config.js,

  vuetify: {
    treeShake: true,
  },

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {
    // analyze: true,
    extractCSS: true,
  },

You would expect a small css bundle size but it's huge instead. Anyone who has a solution for this?

@kat3su
Copy link

kat3su commented Feb 26, 2021

I ran to the same issue too. Only use one VDatePicker component however the building includes the whole main.sass css which is where the 300kb comes from.

@mathe42
Copy link

mathe42 commented Feb 26, 2021

main.scss is allways included.

@mathe42
Copy link

mathe42 commented Feb 26, 2021

See also #382

@kat3su
Copy link

kat3su commented Mar 18, 2021

Not sure if we have any potential fix for this. main.scss is big and including some reset css which affect the global styling

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

No branches or pull requests

8 participants