question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught ReferenceError: Cesium is not defined

See original GitHub issue

Followed Set up webpack config 1 step by step, but when starting the server, get a webpack error saying that “Cesium” isn’t defined.

image

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:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
GRTOcommented, Feb 5, 2020

any updates on this? I got the same error as @garretth95 and Cesium and Resium were installed.

1reaction
garretth95commented, Aug 7, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found