-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathvite.config.mts
More file actions
34 lines (31 loc) · 1.11 KB
/
Copy pathvite.config.mts
File metadata and controls
34 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { fileURLToPath } from 'node:url'
import { tidesDevServerPlugin } from './tides-dev-server.ts'
const maplibreSetup = fileURLToPath(new URL('./app/maplibre.ts', import.meta.url))
// Keeps the import dynamic, so MapLibre stays a lazy chunk the tide table never downloads.
const maplibreWorkerUrl = {
name: 'signalk-tides:maplibre-worker-url',
enforce: 'pre' as const,
resolveId(source: string, importer?: string) {
if (source === 'maplibre-gl' && importer !== maplibreSetup) return maplibreSetup
},
}
// https://vite.dev/config/
export default defineConfig({
base: "./",
publicDir: "app/public",
build: {
outDir: "public",
},
resolve: {
dedupe: ['react', 'react-dom']
},
optimizeDeps: {
// Pre-bundling separates MapLibre from the worker it loads relative to itself,
// so the dev map would request a worker that isn't there and never draw a tile.
exclude: ['maplibre-gl']
},
plugins: [tailwindcss(), react(), tidesDevServerPlugin(), maplibreWorkerUrl],
});