CliffCloud / Leaflet.EasyButton

leaflet control buttons with icons and callbacks
http://cliffcloud.github.io/Leaflet.EasyButton/v1/
MIT License
524 stars 123 forks source link

importing/webpack #90

Closed felluksch closed 5 years ago

felluksch commented 5 years ago

Hi, thanks for the effort you put into this plugin. I have trouble trying to import EasyButton as a node_module to make it work with webpack. This might be more of a webpack-related question but maybe you have an idea on how to solve this.

I tried loading EasyButton into my index.js (which is the entry for webpack bundling) with the following statements in analogy to this thread.

import L from 'leaflet';
import FreeDraw from 'leaflet-freedraw';
import 'leaflet-easybutton';

Importing FreeDraw this way works flawlessly. I get the following error in my console: "leafletWEBPACK_IMPORTED_MODULE0default.a.easyButton is not a function". I haven't fully understood how webpack and modules work but apparently EasyButton lacks export statements (which are necessary to import?). Any advice on how I can make EasyButton work without using a CDN? Help much appreciated!

felluksch commented 5 years ago

To everyone struggling with the same, see the referenced issue for a solution!