Uncaught ReferenceError: Cesium is not defined
See original GitHub issueFollowed Set up webpack config 1
step by step, but when starting the server, get a webpack error saying that “Cesium” isn’t defined.
However, my app runs cesium/resium perfectly fine
Here is my webpack.config.js
:
const HtmlWebpackIncludeAssetsPlugin = require("html-webpack-include-assets-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const Webpack = require("webpack");
module.exports = {
entry: './src/index.js',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
},
},
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
{
test: /\.(png|jpg|gif|ico)$/,
use: [
{
loader: 'file-loader',
options: {},
},
],
},
],
},
externals: {
cesium: "Cesium",
},
output: {
path: __dirname + '/src/',
filename: 'index.min.js',
},
plugins: [
new Webpack.DefinePlugin({
CESIUM_BASE_URL: JSON.stringify("cesium"),
}),
new CopyWebpackPlugin([
{
from: "node_modules/cesium/Build/Cesium",
to: "cesium",
},
]),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: './index.html',
favicon: './src/img/favicon.ico',
}),
new HtmlWebpackIncludeAssetsPlugin({
append: false,
assets: ["cesium/Widgets/widgets.css", "cesium/Cesium.js"],
}),
],
};
Ideally, I’d like to figure out what is causing the error and resolve it, even though the app runs resium/cesium fine.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: Cesium is not defined #89 - GitHub
Followed Set up webpack config 1 step by step, but when starting the server, get a webpack error saying that "Cesium" isn't defined....
Read more >Cesium with Webpack and Typescript: ReferenceError
I solved my problem by making Cesium a global variable in this way: const cs = require("cesium/Cesium"); (<any>window).Cesium = cs.
Read more >define is not defined in Cesium.js - Google Groups
Hello, I have two errors .... Uncaught ReferenceError: define is not defined (in Cesium line 2) and when i try to call the...
Read more >Cesium is not defined
i'm trying to use cesium with openlayers Library. but i get this error. can you help me i'm using typescript for development.
Read more >Uncaught ReferenceError: Cesium is not defined - Issuehunt
Followed Set up webpack config 1 step by step, but when starting the server, get a webpack error saying that "Cesium" isn't defined....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
any updates on this? I got the same error as @garretth95 and Cesium and Resium were installed.
Neither of those suggestions work for me. Adding scripts to HtmlWebpackPlugin, nor adding the script tag in index.html. Tried adding this to index.html:
<script src="../node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
Still confused what the issue is here.