Skip to content

Commit eca8544

Browse files
authored
Merge pull request #1197 from pedroslvieira/olcs-parcel-serve-fix
fix: parcel serve target dist directory
2 parents d0c09b8 + 54302cf commit eca8544

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ npm start
1818
browse http://localhost:1234
1919
```
2020

21+
### OLCesium import
22+
23+
The examples use a compiled version of OLCesium. If you want to use the source code directly you can define an alias.
24+
See https://en.parceljs.org/module_resolution.html#aliases
25+
2126
### The `check` target
2227

2328
```bash

examples/index.html

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,6 @@
33
<head>
44
<meta charset="utf-8"/>
55
<title>OL-Cesium examples</title>
6-
<script type="module">
7-
// In local dev, we need to open /examples/index.html for relative paths to be correct
8-
// This ugly workaround ensures that.
9-
function ensureExamplesUrl(h) {
10-
if (h.endsWith('/')) {
11-
h += 'index.html';
12-
}
13-
const split = h.split('/');
14-
const lastDir = split.at(-2);
15-
if (lastDir !== 'examples') {
16-
split.splice(split.length -1, 0, ['examples']);
17-
return split.join('/');
18-
}
19-
return h;
20-
}
21-
const h = document.location.href.substring(document.location.origin.length);
22-
const newH = ensureExamplesUrl(h);
23-
if (h !== newH) {
24-
document.location.href = newH;
25-
}
26-
</script>
276
</head>
287
<body>
298
<ul>

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
"description": "OpenLayers Cesium integration and plugin library",
55
"scripts": {
66
"test": "node --enable-source-maps --import @swc-node/register/esm-register --test src/olcs/*.test.ts",
7-
"build-examples": "rm -rf dist; parcel build; mkdir -p dist/examples/node_modules/ol; mkdir -p dist/examples/node_modules/cesium/Build/; cp examples/inject_ol_cesium.js dist/examples/; cp node_modules/ol/ol.css dist/examples/node_modules/ol/; cp -R node_modules/cesium/Build/CesiumUnminified node_modules/cesium/Build/Cesium dist/examples/node_modules/cesium/Build/; cp -R examples/data dist/examples/",
7+
"build-examples": "rm -rf dist; parcel build --dist-dir dist/examples && npm run copy-static-dist",
88
"prepare": "tsc --pretty && node buildtools/fix_paths_recast.js; npm run doc",
99
"typecheck": "tsc --pretty --noEmit",
1010
"lint": "eslint src buildtools examples",
1111
"checks": "npm run lint && npm run typecheck",
1212
"doc": "typedoc --name ol-cesium --excludeExternals --out apidoc --entryPoints src/olcs.ts --tsconfig ./tsconfig.json",
13-
"start": "parcel serve --no-autoinstall --target examples",
13+
"copy-static-dist": "mkdir -p dist/examples/node_modules/ol; mkdir -p dist/examples/node_modules/cesium/Build/; cp examples/inject_ol_cesium.js dist/examples/; cp node_modules/ol/ol.css dist/examples/node_modules/ol/; cp -R node_modules/cesium/Build/CesiumUnminified node_modules/cesium/Build/Cesium dist/examples/node_modules/cesium/Build/; cp -R examples/data dist/examples/",
14+
"prestart": "rm -rf dist; npm run copy-static-dist",
15+
"start": "parcel serve ./examples/index.html --dist-dir dist/examples --no-autoinstall & tsc --watch",
1416
"serve-built-examples": "python3 -m http.server --directory dist 12345"
1517
},
1618
"targets": {
1719
"examples": {
1820
"source": "./examples/index.html",
19-
"distDir": "dist/examples/",
2021
"context": "browser",
2122
"publicUrl": "./",
2223
"optimize": true,

0 commit comments

Comments
 (0)