Initial Watermaps import
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
import basicSsl from "@vitejs/plugin-basic-ssl";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
|
||||
const useHttps =
|
||||
process.env.WATERMAPS_HTTPS === "true" ||
|
||||
process.env.SEACOMPASS_HTTPS === "true" ||
|
||||
process.env.HTTPS === "true";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
...(useHttps ? [basicSsl()] : []),
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
includeAssets: ["favicon.svg"],
|
||||
manifest: {
|
||||
name: "Watermaps",
|
||||
short_name: "Watermaps",
|
||||
description: "Bootsrouten, Etappen, Live-Wasserstände, Offline-Navigation, GPS, Wetter und Tide.",
|
||||
theme_color: "#0f4c5c",
|
||||
background_color: "#f5f7f4",
|
||||
display: "standalone",
|
||||
orientation: "portrait",
|
||||
scope: "/",
|
||||
start_url: "/",
|
||||
icons: [
|
||||
{
|
||||
src: "/favicon.svg",
|
||||
sizes: "any",
|
||||
type: "image/svg+xml",
|
||||
purpose: "any maskable"
|
||||
}
|
||||
]
|
||||
},
|
||||
workbox: {
|
||||
navigateFallback: "/",
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /^https:\/\/tiles\.openseamap\.org\/.*/i,
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "openseamap-tiles",
|
||||
cacheableResponse: {
|
||||
statuses: [0, 200]
|
||||
},
|
||||
expiration: {
|
||||
maxEntries: 500,
|
||||
maxAgeSeconds: 60 * 60 * 24 * 14
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: /^https:\/\/tiles\.openfreemap\.org\/.*/i,
|
||||
handler: "StaleWhileRevalidate",
|
||||
options: {
|
||||
// Runtime caching sees only resources requested during normal map
|
||||
// use. It deliberately does not prefetch whole route corridors.
|
||||
cacheName: "openfreemap-visited-resources",
|
||||
cacheableResponse: {
|
||||
statuses: [0, 200]
|
||||
},
|
||||
expiration: {
|
||||
maxEntries: 1_200,
|
||||
maxAgeSeconds: 60 * 60 * 24 * 30
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
],
|
||||
build: {
|
||||
manifest: true,
|
||||
// MapLibre is delivered upstream as one pre-bundled module. Its isolated
|
||||
// chunk is intentionally large and checked separately after each build.
|
||||
chunkSizeWarningLimit: 1_100,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
onlyExplicitManualChunks: true,
|
||||
manualChunks(id) {
|
||||
const normalizedId = id.replaceAll("\\", "/");
|
||||
if (
|
||||
normalizedId.includes("/node_modules/maplibre-gl/") &&
|
||||
!normalizedId.endsWith(".css")
|
||||
) {
|
||||
return "map-engine";
|
||||
}
|
||||
if (
|
||||
normalizedId.includes("/node_modules/react/") ||
|
||||
normalizedId.includes("/node_modules/react-dom/") ||
|
||||
normalizedId.includes("/node_modules/scheduler/")
|
||||
) {
|
||||
return "react-vendor";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://localhost:5174",
|
||||
changeOrigin: true
|
||||
},
|
||||
"/health": {
|
||||
target: "http://localhost:5174",
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user