fix: resolve leaflet marker images through webpack

This commit is contained in:
fromme committed 2026-09-26 09:35:58 +02:00
1 parent f10d784a5c
commit e96dd0f06d
2 files changed
+11 -1

No files matched your search

@@ -1,5 +1,16 @@
import { Controller } from '@hotwired/stimulus'
import L from 'leaflet'
import iconUrl from 'leaflet/dist/images/marker-icon.png'
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png'
import shadowUrl from 'leaflet/dist/images/marker-shadow.png'
// Icon.Default finds its images by reading the url() off .leaflet-default-icon-path and
// stripping a literal `marker-icon.png` off the end - which a content-hashed filename never
// matches, and the `link[href$="leaflet.css"]` fallback does not exist either because the
// CSS is inlined into the bundle. Dropping the _getIconUrl override falls back to plain
// option lookup, so the URLs Webpack emitted are used as they are.
delete L.Icon.Default.prototype._getIconUrl
L.Icon.Default.mergeOptions({ iconUrl, iconRetinaUrl, shadowUrl })
export default class extends Controller {