phegman / vue-mapbox-gl

A Vue.js component for Mapbox GL JS
GNU General Public License v3.0
270 stars 33 forks source link

Better documentation for webpack configuration #21

Closed nickforddev closed 6 years ago

nickforddev commented 6 years ago

I found the documentation to be lacking for including mapbox-gl as a global with Webpack or other transpilers. The suggestion to use window.mapboxgl = require('mapbox-gl') doesn't really work for people using ES6 modules, because it must be included before importing vue-mapbox-gl. Including it in the root js file may work, but I have another suggestion:

I think the cleanest solution is to use shimming, as documented here https://webpack.js.org/guides/shimming/. Maybe a link to this in the docs would make it easier for others using ES6 modules who aren't satisfied binding to window.mapboxgl in their root js file.

I'd be happy to submit a PR, if you'd like. Thanks!

phegman commented 6 years ago

Hi Nick,

Thanks for the suggestion, that is much cleaner than requiring Mapbox GL JS globally. I tried out the shimming and it works great, so I just updated the docs to suggest using Webpack shimming. Feel free to submit a PR if you want to add any other details.

Cheers, Pete