From 198abca917b97428cc32417e9c96ee0327ee10d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=BDdila?= Date: Tue, 27 Jun 2023 15:07:56 +0200 Subject: [PATCH] changed handling default icon URL base --- README.md | 2 -- create-cdn-pr.sh | 2 +- package.json | 14 +++++++------- src/lib/GeocodingControl.svelte | 9 ++++----- vite.config.ts | 12 ++++++------ 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ba12b4c..643a73f 100644 --- a/README.md +++ b/README.md @@ -163,8 +163,6 @@ geocodingControl.addEventListener("optionsVisibilityChange", (e) => { ## POI icons and bundlers -(Skip if the component is used within Svelte webapp.) - POI icons are served from CDN per default. If there is an requirement to serve them from a different location and the control is used in the application which is build with Web Application bundler (like Webpack, Vite) then it is necessary to do some extra cponfiguration. Icons are bundled in the library and you can find them in `node_modules/@maptiler/geocoding-control/icons`. diff --git a/create-cdn-pr.sh b/create-cdn-pr.sh index 425adf7..d82bb3c 100755 --- a/create-cdn-pr.sh +++ b/create-cdn-pr.sh @@ -26,4 +26,4 @@ git reset maptiler-geocoding-control/v$VERSION/*.tgz git commit -m "Add maptiler-geocoding-control v$VERSION" -gh pr create --base main --fill --repo maptiler/cdn.maptiler.com --reviewer "@petrsloup" +gh pr create --base main --fill --repo maptiler/cdn.maptiler.com diff --git a/package.json b/package.json index 71df498..e9f41aa 100644 --- a/package.json +++ b/package.json @@ -32,13 +32,13 @@ "scripts": { "dev": "vite --host", "build": "npm run check && concurrently --names \"SVELTE ,MAPLIBRE,MAPTILER,MAPLIB-C,LEAFLET ,LEAFLE-C,REACT ,TYPES \" \"npm run build-svelte\" \"npm run build-maplibre\" \"npm run build-maptilersdk\" \"npm run build-maplibre-controller\" \"npm run build-leaflet\" \"npm run build-leaflet-controller\" \"npm run build-react\" \"npm run build-types\" && npm run cjs2js && cp dist.svelte/*.svelte* LICENSE README.md package.json dist", - "build-svelte": "svelte-package -o dist.svelte && VITE_FLAVOUR= VITE_LIB_VERSION=$npm_package_version node replace-env-vars.js", - "build-maptilersdk": "VITE_FLAVOUR=maptilersdk vite build", - "build-maplibre": "VITE_FLAVOUR=maplibre vite build", - "build-maplibre-controller": "VITE_FLAVOUR=maplibregl-controller vite build", - "build-leaflet": "VITE_FLAVOUR=leaflet vite build", - "build-leaflet-controller": "VITE_FLAVOUR=leaflet-controller vite build", - "build-react": "VITE_FLAVOUR=react vite build", + "build-svelte": "svelte-package -o dist.svelte && VITE_LIB_VERSION=$npm_package_version node replace-env-vars.js", + "build-maptilersdk": "FLAVOUR=maptilersdk vite build", + "build-maplibre": "FLAVOUR=maplibre vite build", + "build-maplibre-controller": "FLAVOUR=maplibregl-controller vite build", + "build-leaflet": "FLAVOUR=leaflet vite build", + "build-leaflet-controller": "FLAVOUR=leaflet-controller vite build", + "build-react": "FLAVOUR=react vite build", "build-types": "tsc --outDir dist --declaration --emitDeclarationOnly", "cjs2js": "renamer --find '/\\bcjs\\b/' --replace js dist/*cjs*", "clean": "rm -rf dist dist.svelte", diff --git a/src/lib/GeocodingControl.svelte b/src/lib/GeocodingControl.svelte index 6065706..b1041db 100644 --- a/src/lib/GeocodingControl.svelte +++ b/src/lib/GeocodingControl.svelte @@ -83,11 +83,10 @@ export let fetchParameters: RequestInit = {}; - export let iconsBaseUrl = import.meta.env.VITE_FLAVOUR - ? "https://cdn.maptiler.com/maptiler-geocoding-control/v" + - import.meta.env.VITE_LIB_VERSION + - "/icons/" - : "icons/"; + export let iconsBaseUrl = + "https://cdn.maptiler.com/maptiler-geocoding-control/v" + + import.meta.env.VITE_LIB_VERSION + + "/icons/"; export function focus() { input.focus(); diff --git a/vite.config.ts b/vite.config.ts index 6f6bfb6..bfbd439 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,42 +15,42 @@ export default defineConfig({ emptyOutDir: false, lib: // simplify after https://github.com/vitejs/vite/pull/10609 is released - process.env.VITE_FLAVOUR === "leaflet" + process.env.FLAVOUR === "leaflet" ? { fileName: "leaflet", entry: ["src/lib/leaflet.ts"], name: "leafletMaptilerGeocoder", formats: ["es", "umd"], } - : process.env.VITE_FLAVOUR === "maplibre" + : process.env.FLAVOUR === "maplibre" ? { fileName: "maplibregl", entry: ["src/lib/maplibregl.ts"], name: "maplibreglMaptilerGeocoder", formats: ["es", "umd"], } - : process.env.VITE_FLAVOUR === "maptilersdk" + : process.env.FLAVOUR === "maptilersdk" ? { fileName: "maptilersdk", entry: ["src/lib/maptilersdk.ts"], name: "maptilersdkMaptilerGeocoder", formats: ["es", "umd"], } - : process.env.VITE_FLAVOUR === "react" + : process.env.FLAVOUR === "react" ? { fileName: "react", entry: ["src/lib/react.ts"], name: "MapTilerGeocoder", formats: ["es", "umd"], } - : process.env.VITE_FLAVOUR === "leaflet-controller" + : process.env.FLAVOUR === "leaflet-controller" ? { fileName: "leaflet-controller", entry: ["src/lib/leaflet-controller.ts"], name: "leafletMaptilerGeocodingController", formats: ["es", "umd"], } - : process.env.VITE_FLAVOUR === "maplibregl-controller" + : process.env.FLAVOUR === "maplibregl-controller" ? { fileName: "maplibregl-controller", entry: ["src/lib/maplibregl-controller.ts"],