Skip to content

Commit

Permalink
Merge pull request #108 from jahow/fix-gh-pages-deployment
Browse files Browse the repository at this point in the history
Use BASE_URL vite env var to generate import map
  • Loading branch information
jahow authored Jan 6, 2025
2 parents 2c49ce6 + 6ec48d0 commit e2adb85
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions cases/create-importmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ const olVersion = currentUrl.searchParams.get('olVersion');
if (document.currentScript) {
const importMap = document.createElement('script');
importMap.type = 'importmap';
const basePath = document.currentScript.dataset.basePath;

const commonImports = `
"color-rgba": "/node_modules/color-rgba/index.js",
"color-parse": "/node_modules/color-parse/index.js",
"color-name": "/node_modules/color-name/index.js",
"color-name/": "/node_modules/color-name/",
"color-space/": "/node_modules/color-space/",
"rbush": "/node_modules/rbush/index.js",
"quickselect": "/node_modules/quickselect/index.js",
"earcut": "/node_modules/earcut/src/earcut.js"`;
"color-rgba": "${basePath}node_modules/color-rgba/index.js",
"color-parse": "${basePath}node_modules/color-parse/index.js",
"color-name": "${basePath}node_modules/color-name/index.js",
"color-name/": "${basePath}node_modules/color-name/",
"color-space/": "${basePath}node_modules/color-space/",
"rbush": "${basePath}node_modules/rbush/index.js",
"quickselect": "${basePath}node_modules/quickselect/index.js",
"earcut": "${basePath}node_modules/earcut/src/earcut.js"`;

// this import map is used if we're asking for a specific version
if (olVersion) {
Expand All @@ -30,7 +31,7 @@ if (document.currentScript) {
importMap.textContent = `
{
"imports": {
"ol/": "/node_modules/ol/",
"ol/": "${basePath}node_modules/ol/",
${commonImports}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cases/filtering-shapes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Filtering Shapes</title>
<link rel="stylesheet" href="../../style.css">
<script src="../create-importmap.js"></script>
<script src="../create-importmap.js" data-base-path="%BASE_URL%"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion cases/line-rendering/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Line Rendering</title>
<link rel="stylesheet" href="../../style.css">
<script src="../create-importmap.js"></script>
<script src="../create-importmap.js" data-base-path="%BASE_URL%"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion cases/point-rendering/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Point Rendering</title>
<link rel="stylesheet" href="../../style.css">
<script src="../create-importmap.js"></script>
<script src="../create-importmap.js" data-base-path="%BASE_URL%"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion cases/polygon-rendering/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Polygon Rendering</title>
<link rel="stylesheet" href="../../style.css">
<script src="../create-importmap.js"></script>
<script src="../create-importmap.js" data-base-path="%BASE_URL%"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion cases/vector-tiles-rendering/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>Vector Tiles Rendering</title>
<link rel="stylesheet" href="../../style.css">
<script src="../create-importmap.js"></script>
<script src="../create-importmap.js" data-base-path="%BASE_URL%"></script>
</head>

<body>
Expand Down

0 comments on commit e2adb85

Please sign in to comment.