3

I'm using Vue-cli 2 and import Vue2-leaflet modules LMap, LTileLayer in my main.js with

import { LMap, LTileLayer } from 'vue2-leaflet'

By using webpack-bundle-analyzer I can see the bundle size is still 421kb (leaflet-src.js only).

Why is this not decreased significantly, as the docs state;

Is highly suggested to import only the needed modules by doing so: import { LMap, LTileLayer, LMarker } from 'vue2-leaflet'; This will reduce the size of the bundle significantly

nonNumericalFloat
  • 1,348
  • 2
  • 15
  • 32

1 Answers1

3

I'm looking at this same problem. I don't think importing the individual vue2-leaflet components will have any affect on the leaflet-src.js import, which as you stated is over 400kb. It will, however, reduce the vue2-leaflet components. If you load all of the vue2-leaflet components, it will about 242kb (unzipped). This can be reduced significantly with the method you are using.

I would certainly appreciate if leaflet made it possible not to have to use their entire bundle, but I don't believe that's possible.

user1666858
  • 321
  • 2
  • 13