@cesium/engine and @cesium/widgets with vite

Hi all,

I am trying to get @cesium/engine and @cesium/widgets running with Vite. So far, I don’t get any error messages, but 3D tiles and terrain are not displayed at all (although the data is being fetched). My vite.config.js looks like this:

import { defineConfig } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";

const cesiumBaseUrl = "cesiumStatic";

export default defineConfig({
  base: "./",
  define: {
    CESIUM_BASE_URL: JSON.stringify(cesiumBaseUrl),
  },
   plugins: [
            viteStaticCopy({
                targets: [
                    { src: `node_modules/@cesium/engine/Source/Assets`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/Core`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/Renderer`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/Scene`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/Shaders`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/ThirdParty`, dest: cesiumBaseUrl },
                    { src: `node_modules/@cesium/engine/Source/Workers`, dest: cesiumBaseUrl },

                    { src: `node_modules/@cesium/widgets/Source`, dest: cesiumBaseUrl },
                ],
            })
        ]
});

Does anyone know how to solve this problem? I’d like to build Cesium myself so that I have control over things like tree-shaking, compression, etc.

Thanks in advance.

Best regards

Hi there,

Do you see any errors in the developer console? Any 404’s in particular?

Did you set your personal Cesium Ion token ?

You can have a look at demo-cesium-widget

Note: I’m the author of vite-plugin-cesium-engine