vuejs / ui

💻 UI components for official Vue organization apps
https://vuejs.github.io/ui/
1.33k stars 91 forks source link

Reduce bundle size by removing the injected XML icons library #21

Closed TotomInc closed 4 years ago

TotomInc commented 5 years ago

I recently analyzed the size of my app bundle with webpack-bundle-analyze and it looks like @vue/ui/dist/vue-ui.esm.js takes a lot of size in my app bundle (around 1/3 of the total size).

I took a look at the vue-ui.esm.js bundle and indeed there is some sort of inline XML taking a lot of space at the beginning of the file (I extracted this XML to another file and it's 279k characters which is around 280 ko).

This XML seems to be related to icons used in the library (Material Design Icons?) as I find many XML symbols IDs with names like ic_account_balance_wallet or ic_account_circle.

Is there a reason for the icon library content to be injected in the vue.esm.js instead of using a .css file of the icon library? Because I would like to use PurgeCSS on non-used style imported in my project, which is not possible the way @vue/ui dist output is actually.

Example of what the XML contains:

<symbol viewBox=\"0 0 24 24\" id=\"ic_account_circle_24px\"><path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2a7.2 7.2 0 0 1-6-3.22c.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08a7.2 7.2 0 0 1-6 3.22z\"/></symbol>

image