coreui / coreui-icons

CoreUI Free Icons - Premium designed free icon set with marks in SVG, Webfont and raster formats
https://coreui.io/icons/
Other
1.99k stars 153 forks source link

CoreUI icons package is huge! #34

Closed eddivalen closed 3 years ago

eddivalen commented 3 years ago

How can I reduce the bundle size of the icons package?

Currently, the size is 10.2MB

I’m just importing these ones:

//icons.js    
import {
      cilEnvelopeClosed,
      cilEnvelopeOpen,
      cilMagnifyingGlass,
      cilMoon,
      cilSpeedometer,
      cilSun,
      cilAccountLogout,
      cilUser,
      cilXCircle,
      cilX,
    } from '@coreui/icons'

import { logo } from './logo'

export const iconsSet = Object.assign({}, { logo }, {
  cilEnvelopeClosed,
  cilEnvelopeOpen,
  cilMagnifyingGlass,
  cilMoon,
  cilSpeedometer,
  cilSun,
  cilAccountLogout,
  cilUser,
  cilXCircle,
  cilX,
})
//main.js
import { iconsSet as icons } from './assets/icons/icons.js'
...
...
...
new Vue({
  el: '#app',
  router,
  store,
  icons
  components: {
    App
  },
  template: '<App/>',
  apolloProvider: createProvider(),
})

image

xidedix commented 3 years ago

@eddivalen huh? Obviously you've got imports of freeSet, brandSet and flagSet somewhere in the code. I suspect src/views/icons.

With your example I've got in production bundle: image

eddivalen commented 3 years ago

Hey @xidedix, thanks for your answer, I just made a build in production mode and I get that 6 KB

Do you know why this only works in production mode?

xidedix commented 3 years ago

@eddivalen Webpack production mode configuration option enables tree shaking and other optimizations. It uses ModuleConcatenationPlugin to make it work. All in all, what's the point of tree shaking on development mode?