Skip to content

Commit

Permalink
Merge pull request #1197 from pedroslvieira/olcs-parcel-serve-fix
Browse files Browse the repository at this point in the history
fix: parcel serve target dist directory
  • Loading branch information
gberaudo authored Jun 21, 2024
2 parents d0c09b8 + 54302cf commit eca8544
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ npm start
browse http://localhost:1234
```

### OLCesium import

The examples use a compiled version of OLCesium. If you want to use the source code directly you can define an alias.
See https://en.parceljs.org/module_resolution.html#aliases

### The `check` target

```bash
Expand Down
21 changes: 0 additions & 21 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,6 @@
<head>
<meta charset="utf-8"/>
<title>OL-Cesium examples</title>
<script type="module">
// In local dev, we need to open /examples/index.html for relative paths to be correct
// This ugly workaround ensures that.
function ensureExamplesUrl(h) {
if (h.endsWith('/')) {
h += 'index.html';
}
const split = h.split('/');
const lastDir = split.at(-2);
if (lastDir !== 'examples') {
split.splice(split.length -1, 0, ['examples']);
return split.join('/');
}
return h;
}
const h = document.location.href.substring(document.location.origin.length);
const newH = ensureExamplesUrl(h);
if (h !== newH) {
document.location.href = newH;
}
</script>
</head>
<body>
<ul>
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
"description": "OpenLayers Cesium integration and plugin library",
"scripts": {
"test": "node --enable-source-maps --import @swc-node/register/esm-register --test src/olcs/*.test.ts",
"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/",
"build-examples": "rm -rf dist; parcel build --dist-dir dist/examples && npm run copy-static-dist",
"prepare": "tsc --pretty && node buildtools/fix_paths_recast.js; npm run doc",
"typecheck": "tsc --pretty --noEmit",
"lint": "eslint src buildtools examples",
"checks": "npm run lint && npm run typecheck",
"doc": "typedoc --name ol-cesium --excludeExternals --out apidoc --entryPoints src/olcs.ts --tsconfig ./tsconfig.json",
"start": "parcel serve --no-autoinstall --target examples",
"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/",
"prestart": "rm -rf dist; npm run copy-static-dist",
"start": "parcel serve ./examples/index.html --dist-dir dist/examples --no-autoinstall & tsc --watch",
"serve-built-examples": "python3 -m http.server --directory dist 12345"
},
"targets": {
"examples": {
"source": "./examples/index.html",
"distDir": "dist/examples/",
"context": "browser",
"publicUrl": "./",
"optimize": true,
Expand Down

0 comments on commit eca8544

Please sign in to comment.