Repository navigation
Expand file tree
/
Copy pathgulpfile.apps.js
More file actions
144 lines (128 loc) · 3.77 KB
/
Copy pathgulpfile.apps.js
File metadata and controls
144 lines (128 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// @ts-check
import { mkdirSync } from "fs";
import { join } from "path";
import { finished } from "stream/promises";
import gulp from "gulp";
import yargs from "yargs";
import { buildSandcastleApp } from "./scripts/buildSandcastle.js";
import {
bundleWorkers,
defaultESBuildOptions,
handleBuildWarnings,
} from "./scripts/build-utilities.js";
import { build as esbuild } from "esbuild";
const isProduction = process.env.PROD === "true";
export async function buildCesiumViewer() {
const cesiumViewerOutputDirectory = isProduction
? "Build/CesiumViewer"
: "Build/Apps/CesiumViewer";
mkdirSync(cesiumViewerOutputDirectory, { recursive: true });
const result = await esbuild({
...defaultESBuildOptions(),
entryPoints: [
"Apps/CesiumViewer/CesiumViewer.js",
"Apps/CesiumViewer/CesiumViewer.css",
],
minify: true,
loader: {
".gif": "text",
".png": "text",
},
format: "iife",
// Configure Cesium base path to use built
define: { CESIUM_BASE_URL: `"."` },
outdir: cesiumViewerOutputDirectory,
outbase: "Apps/CesiumViewer",
logLevel: "error", // print errors immediately, and collect warnings so we can filter out known ones
});
handleBuildWarnings(result);
await esbuild({
...defaultESBuildOptions(),
entryPoints: ["packages/widgets/Source/InfoBox/InfoBoxDescription.css"],
minify: true,
loader: {
".gif": "text",
".png": "text",
},
outdir: join(cesiumViewerOutputDirectory, "Widgets"),
outbase: "packages/widgets/Source/",
});
await bundleWorkers({
minify: true,
removePragmas: true,
path: cesiumViewerOutputDirectory,
});
const stream = gulp
.src(
[
"Apps/CesiumViewer/**",
"!Apps/CesiumViewer/Images",
"!Apps/CesiumViewer/**/*.js",
"!Apps/CesiumViewer/**/*.css",
],
{
encoding: false,
},
)
.pipe(
gulp.src(
[
"Build/Cesium/Assets/**",
"Build/Cesium/Workers/**",
"Build/Cesium/ThirdParty/**",
"Build/Cesium/Widgets/**",
"!Build/Cesium/Widgets/**/*.css",
],
{
base: "Build/Cesium",
encoding: false,
},
),
)
.pipe(gulp.src(["web.config"]))
.pipe(gulp.dest(cesiumViewerOutputDirectory));
await finished(stream);
return stream;
}
export async function buildSandcastle() {
const argv = await yargs(process.argv.slice(5))
.options({
"outer-origin": {
type: "string",
description:
"The outer origin for the Sandcastle App. Defaults to localhost:8080 if not specified",
},
"inner-origin": {
type: "string",
description:
"The inner origin for the Sandcastle viewer iframe. Defaults to the outer-origin if not specified or localhost:8081 if neither are specified",
},
embeddings: {
type: "boolean",
default: true,
description:
"Generate semantic search embeddings. Pass --no-embeddings to skip. Can also be set via SANDCASTLE_NO_EMBEDDINGS=1.",
},
})
.help(false)
.version(false)
.strict()
.parse();
let outerOrigin = argv.outerOrigin ?? "http://localhost:8080";
let innerOrigin =
argv.innerOrigin ?? argv.outerOrigin ?? "http://localhost:8081";
if (process.env.SANDCASTLE_ORIGIN) {
outerOrigin = process.env.SANDCASTLE_ORIGIN;
innerOrigin = outerOrigin;
}
const noEmbeddings =
!argv.embeddings || !!process.env.SANDCASTLE_NO_EMBEDDINGS;
return buildSandcastleApp({
outputToBuildDir: isProduction,
includeDevelopment: !isProduction,
outerOrigin,
innerOrigin,
generateEmbeddings: noEmbeddings ? false : undefined,
});
}
export const buildApps = gulp.parallel(buildCesiumViewer, buildSandcastle);