From 8b0fa254a50630efc3464f9bf054b203f2fc253e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=BDdila?= Date: Fri, 5 Jul 2024 15:10:12 +0200 Subject: [PATCH] fixed OL globals (#40) --- vite.config.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 7e85602..3bcc683 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -83,7 +83,7 @@ export default defineConfig({ "leaflet", "react", "react-dom", - "ol", + /^ol(\/.*)?/, ], output: [ { @@ -100,13 +100,18 @@ export default defineConfig({ assetFileNames: "[name].[ext]", // Provide global variables to use in the UMD build for externalized deps - globals: { - "@maptiler/sdk": "maptilersdk", - "maplibre-gl": "maplibregl", - leaflet: "L", - react: "React", - "react-dom": "ReactDOM", - ol: "ol", + globals(name) { + const global = { + "@maptiler/sdk": "maptilersdk", + "maplibre-gl": "maplibregl", + leaflet: "L", + react: "React", + "react-dom": "ReactDOM", + }[name]; + + return ( + global ?? (name.startsWith("ol") ? name.replace(/\//g, ".") : "") + ); }, }, ],