Reputation: 651
I am trying to setup cesium and resium for react typescript and got stuck on the very initial steps. I am currently referencing steps from the following resium website, from here I have installed the packages and attempted to setup webpack based on the following steps. Based on the steps i installed the following package
The following example was also presented so i attempted to mimic the settings as much as possible creating and tweaking the following files in my root directory
Once done I changed the following setting CESIUM_BASE_URL: JSON.stringify("/cesium")
in webpack.config.js
to point to my python server(https://localhost:5000
) for the necessary tiles.
With this I expected the error to at least go away or maybe even stating another error such as "Asset XXX not found". But the error stating DeveloperError: Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL
still persists.
I have also tried setting a variable for CESIUM_BASE_URL
in env.local
but it still doesn't work. Any pointers or guidance to any missing steps will be greatly appreciated.
Upvotes: 3
Views: 6502
Reputation: 1
configureWebpack: {
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: Path.resolve('./node_modules/cesium/Source/Workers'), to: 'Workers' },
{ from: Path.resolve('./node_modules/cesium/Source/Assets'), to: 'Assets' },
{ from: Path.resolve('./node_modules/cesium/Source/Widgets'), to: 'Widgets' },
{ from: Path.resolve('./node_modules/cesium/Source/ThirdParty/Workers'), to: 'WoThirdParty/Workersrkers' },
]
}),
new webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify('./')
})
],
},
Upvotes: 0
Reputation: 332
The best way to do this is probably in your webpack.config.js
file by adding the CopyPlugin
from webpack.
In the config:
new DefinePlugin({
CESIUM_BASE_URL: JSON.stringify(env.CESIUM_BASE_URL || 'http://localhost/'),
}),
Upvotes: 1
Reputation: 6609
Add this script before others (or just before cesium) to your index.html
...
</body>
<script>
window.CESIUM_BASE_URL = 'https://localhost:5000/';
<script>
<script>
...
Resources:
https://cesium.com/blog/2016/01/26/cesium-and-webpack/#ive-already-got-webpack-set-up-just-tell-me-how-to-use-cesium
https://github.com/opensensorhub/osh-js/issues/55
Upvotes: 3