fix(map): import leaflet CSS statically so Vite emits the file
Dynamic await import of CSS only emits a JS shim (leaflet-src.HASH.js) that injects styles at runtime, but the actual stylesheet file (leaflet.HASH.css) is never written to dist/_astro/, causing 404s on Astro's preload helper. Static top-level import is processed at build time and emits the CSS. Lazy-loading is preserved: the component still hydrates only with client:media="(min-width: 900px)" in index.astro.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useRef } from 'preact/hooks';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import type { Aviso } from '../lib/types';
|
||||
import { municipioCoords } from '../lib/fixtures';
|
||||
|
||||
@@ -18,7 +19,6 @@ export default function MapView({ avisos }: Props) {
|
||||
|
||||
(async () => {
|
||||
const L = await import('leaflet');
|
||||
await import('leaflet/dist/leaflet.css');
|
||||
if (!mapEl.current) return;
|
||||
|
||||
map = L.map(mapEl.current, {
|
||||
|
||||
Reference in New Issue
Block a user