coryasilva / Leaflet.ExtraMarkers

Custom Markers for Leaflet JS based on Awesome Markers
MIT License
330 stars 125 forks source link

Vite bundler support (需要显式引入 L 代表的 leaflet 包,否则会导致打包异常) #58

Open zwq000 opened 3 years ago

zwq000 commented 3 years ago

代码入口没有引入 L 代表的 leaflet 包,导致使用 vite 打包 'vite build' 之后产生异常, undefine L. 现代前端项目通过 webpack 打包, 如果通过 vite build 打包前端文件,无法解析到 对 leaflet 的依赖关系. 改进方法 leaflet.extramarkers.js 文件 import * as L from 'leaflet'

coryasilva commented 1 month ago

Google translation

The code entry does not introduce the leaflet package represented by L, resulting in an exception after using vite package 'vite build', undefine L. Modern front-end projects are packaged through webpack. If the front-end files are packaged through vite build, the dependency on leaflet cannot be resolved. Improvement method