If you need to access Cesium, there are a few ways to go about it. One option is to simply retrieve Cesium from the node_modules
folder where it is being served. During debugging, it is recommended to use the un-minified version:
<script src="node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
<style>
@import url(node_modules/cesium/Build/CesiumUnminified/Widgets/widgets.css);
</style>
For production purposes, opt for the minified version instead:
<script src="node_modules/cesium/Build/Cesium/Cesium.js"></script>
<style>
@import url(node_modules/cesium/Build/Cesium/Widgets/widgets.css);
</style>
Another approach is to utilize npm
to download require.js
, and then selectively require only the necessary modules of Cesium from the source tree located in node_modules\cesium\Source
. This method reduces the amount of JavaScript loaded into your project compared to importing the entire combined file. It also simplifies debugging due to the individual files. Be mindful that this technique may result in more network requests, making it less ideal for direct usage in a production environment without some form of build system to consolidate and minimize the files you utilize.
For further information, refer to the detailed blog post introducing npm cesium on the official Cesium website. (authored by Matt Amato, along with additional insights provided in the comments below)