Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/Common/Mapbox/MapBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
*/

import { onMounted, onUnmounted, provide, readonly, ref } from 'vue'
import { Map as MaplibreMap } from 'maplibre-gl'
import { Map as MaplibreMap, setWorkerUrl } from 'maplibre-gl'
// maplibre v6 loads its worker as a sibling module via a runtime-computed
// URL, which the bundler can't see - the file never gets emitted and the
// request falls through to the SPA catch-all (text/html -> dead worker,
// blank map). ?worker&url makes Vite bundle the worker with its imports
// and hands us the hashed URL to register instead.
import maplibreWorkerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'

import 'maplibre-gl/dist/maplibre-gl.css';

setWorkerUrl(maplibreWorkerUrl)

/**
* The MapLibre instance
*/
Expand Down
9 changes: 9 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ export default defineConfig(() => {

return {
plugins: [tailwindcss(), vue(), svgLoader()],
worker: {
rollupOptions: {
output: {
entryFileNames: `assets/[name]-[hash]-${buildId}.js`,
chunkFileNames: `assets/[name]-[hash]-${buildId}.js`,
assetFileNames: `assets/[name]-[hash]-${buildId}[extname]`,
},
},
},
resolve: {
alias: [
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
Expand Down
Loading