Assets path in webpack compiled Cesium

42 views
Skip to first unread message

tho...@gmail.com

unread,
Aug 3, 2018, 9:54:35 AM8/3/18
to cesium-dev
Hello,

I successfully followed this tutorial https://cesiumjs.org/tutorials/cesium-and-webpack/ .

Where we copy the static assets, such as "Assets", webpack puts the Assets into js/mycesium/Assets, which is correct. This is my modification to the tutorial.

CODE FROM webpack.config.js:
CopywebpackPlugin([ { from: path.join(cesiumSource, 'js/mycesium/Assets'), to: 'include/olcs-1.0/Assets' } ]),

However, inside the compiled app.js, the paths to Assets/ is still off the top level root. The browser is throwing 404 not found on all the assets.

I'm doing this because I will have several different apps that will use the same mycesium build (app.js). Assets, Workers, and Widgets will not live on the same level as index.html They will be in <context_root>/js/mycesium/

The question is, how to reflect these paths in the compiled js file?

Thanks in advance for any pointers!

Gabby Getz

unread,
Aug 6, 2018, 2:56:12 PM8/6/18
to cesium-dev
Hi there,

When you define the base path with:

        new webpack.DefinePlugin({
            // Define relative base path in cesium for loading assets
            CESIUM_BASE_URL: JSON.stringify('')
        })

Instead of an empty string, provide the path you would like to use, relative to the Cesium source, at which you are loading you Assets, Workers, and Widgets.

Thanks!
Gabby
Reply all
Reply to author
Forward
0 new messages