So I am just starting out, and in the CesiumJS tutorial it said I had to get webpack setup so I could serve local files. So I went to the demo , Cesium Webpack 5 link and grabbed it to see how it works. Before I did any of the npm builds or anything I de-commented the Ion.defaultAccessToken line in index.js and pasted in the string value from my account.
I tried adding a Cesium. before the Ion.defaultAccessToken line on a clean version and it didn’t matter, got the same error.
When I do NPM start it works just fine, but I get the banner at the bottom saying I’m using the default access key? What gives?
Maybe I’m totally misunderstanding this, but from what the documentation seemed to imply. If I want to do localhost development, I have to use webpack or something similar? I’m not a new developer, but have never done web dev (for reasons like this lol)
Hey @chris_s! Thanks for the question, sorry you’re running into issues getting set up.
You do not have to use Webpack but I would recommend some sort of build system (webpack, vite, esbuild, etc) if you’re planning to build an application that’s more than a single file/page and want to take advantage of separating functions and classes and logic between multiple files. If you follow our quickstart for CesiumJS and just put the first code example in an html file it should work by itself without webpack.
That said, the Webpack 5 example should “just work” out of the box, even if you provide your own ion token. I tried this myself with a fresh clone of the example repo and it’s working and doesn’t show the “default token” message. The only other thing I had to change is add Ion
as an import at the top of the file because it’s not there by default (because it’s not used unless you uncomment that line, I might change this).
import {
Viewer,
Cartesian3,
Math,
Terrain,
createOsmBuildingsAsync,
Ion // <-- this line
} from "cesium";
but without that the app should just show a white screen so I’m a little confused how you had it running regardless.
Would you be able to share the full index.js
file you’re using if that change still doesn’t get it to work?