-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Sandcastle build config updates #12904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,291
−800
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
f490f63
central sandcastle build function, bundle esm packages
jjspace 814cb73
remove duplicated configs
jjspace f7c4d62
dont include dev sandcastles in prod
jjspace aabcb3d
add commit sha to build for CI
jjspace f3f4075
build TS for sandcastle
jjspace 4de8de1
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace dcc4ec1
fix ci build double //
jjspace 97f606d
move import inside module declaration in package types
jjspace 4aab565
Use proper URLs for import statements
javagl 2fcefac
make sure imports are strings
jjspace 20f3edc
Merge pull request #12911 from CesiumGS/sandcastle-build-updates-windows
jjspace d350020
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace 63c8ccb
clarify build option
jjspace 1bd41e9
further isolate sandcastle build process
jjspace d83fb76
switch from ts api to tsc cli
jjspace 26a011d
remove extra logs
jjspace 0f7a9c8
switch deployed sandcastle directory
jjspace c708661
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace b586c14
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace c4e8eea
switch to relative routes for non-prod builds
jjspace aaf4ae1
move and trim build config
jjspace b695f5d
adjust prod GH workflow
jjspace 61d330a
correctly build sandcastle for zip file
jjspace f3ecf5b
build sandcastle on server start when it doesn't exist
jjspace 00dce5a
update release index url to new sandcastle
jjspace dde0e07
small cleanup, remove excess changes
jjspace fd85408
adjust config structure
jjspace bee0278
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace 3b6dd1e
update comment
jjspace da2dd8a
update function names
jjspace 4530967
switch dev-sandcastle to main branch
jjspace b74d62d
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace ba045e7
convert to options params for clarity
jjspace b478c3f
rename arguments and functions for clarity
jjspace 8b212bd
rebuild package bundles in dev server
jjspace 22df371
extract gulp tasks to help avoid dynamic imports
jjspace 5cc27ef
small doc link change
jjspace ba5b5d7
Merge branch 'main' into sandcastle-build-updates
ggetz 9675ce5
don't include engine bundle in npm package
jjspace c59e106
Merge remote-tracking branch 'origin/main' into sandcastle-build-updates
jjspace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| import { join } from "path"; | ||
| import { finished } from "stream/promises"; | ||
|
|
||
| import gulp from "gulp"; | ||
| import gulpReplace from "gulp-replace"; | ||
| import { buildSandcastleApp } from "./scripts/buildSandcastle.js"; | ||
| import { mkdirp } from "mkdirp"; | ||
| import { bundleWorkers, defaultESBuildOptions } from "./scripts/build.js"; | ||
| import { build as esbuild } from "esbuild"; | ||
|
|
||
| const isProduction = process.env.PROD === "true"; | ||
|
|
||
| // Print an esbuild warning | ||
| function printBuildWarning({ location, text }) { | ||
| const { column, file, line, lineText, suggestion } = location; | ||
|
|
||
| let message = `\n | ||
| > ${file}:${line}:${column}: warning: ${text} | ||
| ${lineText} | ||
| `; | ||
|
|
||
| if (suggestion && suggestion !== "") { | ||
| message += `\n${suggestion}`; | ||
| } | ||
|
|
||
| console.log(message); | ||
| } | ||
|
|
||
| // Ignore `eval` warnings in third-party code we don't have control over | ||
| function handleBuildWarnings(result) { | ||
| for (const warning of result.warnings) { | ||
| if ( | ||
| !warning.location.file.includes("protobufjs.js") && | ||
| !warning.location.file.includes("Build/Cesium") | ||
| ) { | ||
| printBuildWarning(warning); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function buildLegacySandcastle() { | ||
| const streams = []; | ||
| let appStream = gulp.src( | ||
| [ | ||
| "Apps/Sandcastle/**", | ||
| "!Apps/Sandcastle/load-cesium-es6.js", | ||
| "!Apps/Sandcastle/images/**", | ||
| "!Apps/Sandcastle/gallery/**.jpg", | ||
| ], | ||
| { | ||
| encoding: false, | ||
| }, | ||
| ); | ||
|
|
||
| if (isProduction) { | ||
| // Remove swap out ESM modules for the IIFE build | ||
| appStream = appStream | ||
| .pipe( | ||
| gulpReplace( | ||
| ' <script type="module" src="../load-cesium-es6.js"></script>', | ||
| ' <script src="../CesiumUnminified/Cesium.js"></script>\n' + | ||
| ' <script>window.CESIUM_BASE_URL = "../CesiumUnminified/";</script>', | ||
| ), | ||
| ) | ||
| .pipe( | ||
| gulpReplace( | ||
| ' <script type="module" src="load-cesium-es6.js"></script>', | ||
| ' <script src="CesiumUnminified/Cesium.js"></script>\n' + | ||
| ' <script>window.CESIUM_BASE_URL = "CesiumUnminified/";</script>', | ||
| ), | ||
| ) | ||
| // Fix relative paths for new location | ||
| .pipe(gulpReplace("../../../Build", "..")) | ||
| .pipe(gulpReplace("../../../Source", "../CesiumUnminified")) | ||
| .pipe(gulpReplace("../../Source", ".")) | ||
| .pipe(gulpReplace("../../../ThirdParty", "./ThirdParty")) | ||
| .pipe(gulpReplace("../../ThirdParty", "./ThirdParty")) | ||
| .pipe(gulpReplace("../ThirdParty", "./ThirdParty")) | ||
| .pipe(gulpReplace("../Apps/Sandcastle", ".")) | ||
| .pipe(gulpReplace("../../SampleData", "../SampleData")) | ||
| .pipe( | ||
| gulpReplace("../../Build/Documentation", "/learn/cesiumjs/ref-doc/"), | ||
| ) | ||
| .pipe(gulp.dest("Build/Sandcastle")); | ||
| } else { | ||
| // Remove swap out ESM modules for the IIFE build | ||
| appStream = appStream | ||
| .pipe( | ||
| gulpReplace( | ||
| ' <script type="module" src="../load-cesium-es6.js"></script>', | ||
| ' <script src="../../../Build/CesiumUnminified/Cesium.js"></script>\n' + | ||
| ' <script>window.CESIUM_BASE_URL = "../../../Build/CesiumUnminified/";</script>', | ||
| ), | ||
| ) | ||
| .pipe( | ||
| gulpReplace( | ||
| ' <script type="module" src="load-cesium-es6.js"></script>', | ||
| ' <script src="../../CesiumUnminified/Cesium.js"></script>\n' + | ||
| ' <script>window.CESIUM_BASE_URL = "../../CesiumUnminified/";</script>', | ||
| ), | ||
| ) | ||
| // Fix relative paths for new location | ||
| .pipe(gulpReplace("../../../Build", "../../..")) | ||
| .pipe(gulpReplace("../../Source", "../../../Source")) | ||
| .pipe(gulpReplace("../../ThirdParty", "../../../ThirdParty")) | ||
| .pipe(gulpReplace("../../SampleData", "../../../../Apps/SampleData")) | ||
| .pipe(gulpReplace("Build/Documentation", "Documentation")) | ||
| .pipe(gulp.dest("Build/Apps/Sandcastle")); | ||
| } | ||
| streams.push(appStream); | ||
|
|
||
| let imageStream = gulp.src( | ||
| ["Apps/Sandcastle/gallery/**.jpg", "Apps/Sandcastle/images/**"], | ||
| { | ||
| base: "Apps/Sandcastle", | ||
| encoding: false, | ||
| }, | ||
| ); | ||
| if (isProduction) { | ||
| imageStream = imageStream.pipe(gulp.dest("Build/Sandcastle")); | ||
| } else { | ||
| imageStream = imageStream.pipe(gulp.dest("Build/Apps/Sandcastle")); | ||
| } | ||
| streams.push(imageStream); | ||
|
|
||
| if (isProduction) { | ||
| const fileStream = gulp | ||
| .src(["ThirdParty/**"], { encoding: false }) | ||
| .pipe(gulp.dest("Build/Sandcastle/ThirdParty")); | ||
| streams.push(fileStream); | ||
|
|
||
| const dataStream = gulp | ||
| .src(["Apps/SampleData/**"], { encoding: false }) | ||
| .pipe(gulp.dest("Build/Sandcastle/SampleData")); | ||
| streams.push(dataStream); | ||
| } | ||
|
|
||
| let standaloneStream = gulp | ||
| .src(["Apps/Sandcastle/standalone.html"]) | ||
| .pipe(gulpReplace("../../../", ".")) | ||
| .pipe( | ||
| gulpReplace( | ||
| ' <script type="module" src="load-cesium-es6.js"></script>', | ||
| ' <script src="../CesiumUnminified/Cesium.js"></script>\n' + | ||
| ' <script>window.CESIUM_BASE_URL = "../CesiumUnminified/";</script>', | ||
| ), | ||
| ) | ||
| .pipe(gulpReplace("../../Build", ".")); | ||
| if (isProduction) { | ||
| standaloneStream = standaloneStream.pipe(gulp.dest("Build/Sandcastle")); | ||
| } else { | ||
| standaloneStream = standaloneStream.pipe( | ||
| gulp.dest("Build/Apps/Sandcastle"), | ||
| ); | ||
| } | ||
| streams.push(standaloneStream); | ||
|
|
||
| return Promise.all(streams.map((s) => finished(s))); | ||
| } | ||
|
|
||
| async function buildCesiumViewer() { | ||
| const cesiumViewerOutputDirectory = isProduction | ||
| ? "Build/CesiumViewer" | ||
| : "Build/Apps/CesiumViewer"; | ||
| mkdirp.sync(cesiumViewerOutputDirectory); | ||
|
|
||
| const config = defaultESBuildOptions(); | ||
| config.entryPoints = [ | ||
| "Apps/CesiumViewer/CesiumViewer.js", | ||
| "Apps/CesiumViewer/CesiumViewer.css", | ||
| ]; | ||
| config.bundle = true; // Tree-shaking is enabled automatically | ||
| config.minify = true; | ||
| config.loader = { | ||
| ".gif": "text", | ||
| ".png": "text", | ||
| }; | ||
| config.format = "iife"; | ||
| // Configure Cesium base path to use built | ||
| config.define = { CESIUM_BASE_URL: `"."` }; | ||
| config.outdir = cesiumViewerOutputDirectory; | ||
| config.outbase = "Apps/CesiumViewer"; | ||
| config.logLevel = "error"; // print errors immediately, and collect warnings so we can filter out known ones | ||
| const result = await esbuild(config); | ||
|
|
||
| handleBuildWarnings(result); | ||
|
|
||
| await esbuild({ | ||
| entryPoints: ["packages/widgets/Source/InfoBox/InfoBoxDescription.css"], | ||
| minify: true, | ||
| bundle: 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", | ||
| nodir: true, | ||
| encoding: false, | ||
| }, | ||
| ), | ||
| ) | ||
| .pipe(gulp.src(["web.config"])) | ||
| .pipe(gulp.dest(cesiumViewerOutputDirectory)); | ||
|
|
||
| await finished(stream); | ||
| return stream; | ||
| } | ||
|
|
||
| export async function buildSandcastle() { | ||
| return buildSandcastleApp({ | ||
| outputToBuildDir: isProduction, | ||
| includeDevelopment: !isProduction, | ||
| }); | ||
| } | ||
|
|
||
| export const buildApps = gulp.parallel( | ||
| buildCesiumViewer, | ||
| buildLegacySandcastle, | ||
| buildSandcastle, | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.