Unable to find static Cesium files using craco
Closed this issue · 1 comments
Versions:
- "@craco/craco": "^7.1.0"
- "craco-cesium": "^1.2.0"
- "resium": "^1.17.2"
- "copy-webpack-plugin": "^11.0.0"
I followed the exact procedure described in the README using craco.config.js
. However, I getting this error on the console
GET http://localhost:3000/cesiumStatic/Assets/approximateTerrainHeights.json 404 (Not Found)
And also this error on the main page (screenshot)
It looks like I need to copy over the directories from the node_modules
folder during the build step, and configure the CESIUM_BASE_URL
variable as suggested here: https://cesium.com/learn/cesiumjs-learn/cesiumjs-webpack/#add-cesiumjs-to-a-webpack-app
I modified the craco.config.js
to the following, but i still keep getting the same error.
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const cesiumSource = "./node_modules/cesium/Build/Cesium";
const cesiumBaseUrl = "/cesiumStatic";
module.exports = {
plugins: [
{
plugin: require("craco-cesium")()
},
],
webpack: {
plugins: {
add: [
new CopyWebpackPlugin({
patterns: [
{
from: path.join(cesiumSource, "Workers"),
to: `${cesiumBaseUrl}/Workers`,
},
{
from: path.join(cesiumSource, "ThirdParty"),
to: `${cesiumBaseUrl}/ThirdParty`,
},
{
from: path.join(cesiumSource, "Assets"),
to: `${cesiumBaseUrl}/Assets`,
},
{
from: path.join(cesiumSource, "Widgets"),
to: `${cesiumBaseUrl}/Widgets`,
}
]
})
]
}
}
};
Im not super familiar with webpack
and craco
, so unsure if I am refactoring correctly. Any suggestions?
Thanks in advance
Nevermind, I figured it out a few weeks ago.
Posting here for other in case.
I didn't have to do any of this copying over or setting the base url.
I removed everything under the webpack
section in the craco.config.js
and removed setting the CESIUM_BASE_URL
, and it worked.