Registry / web-framework / vite-plugin-cesium

vite-plugin-cesium

JSON →
library1.2.23jsnpmunverified

Vite plugin that simplifies integrating CesiumJS into Vite projects. Current stable version is 1.2.23, with active maintenance and frequent patches. It handles Cesium's static assets, worker files, and CSS, providing a seamless development experience. Key differentiators: no manual copy steps, configurable rebuildCesium option, and support for Cesium Ion SDK paths. Requires Cesium ^1.95.0 and Vite >=2.7.1.

npm install vite-plugin-cesium
INSTALL
IMPORT
SIG · VITE-PLUGIN-CESIUM
V
vite-plugin-cesium
web-frameworkjavascriptv1.2.23
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (cesium function)
import cesium from 'vite-plugin-cesium';
const cesium = require('vite-plugin-cesium');
ESM-only; CommonJS require will fail. Use named export in ts if needed: import cesium from 'vite-plugin-cesium'.
Cesium.Viewer
import { Viewer } from 'cesium';
import Viewer from 'cesium';
Cesium exports are named, not default. Use named imports for specific classes.
Cesium (global object)
import * as Cesium from 'cesium';
const Cesium = require('cesium');
For accessing the entire Cesium namespace, use namespace import. CommonJS require may cause issues with static assets.

Minimal setup: add plugin to vite.config.js, import Viewer from cesium, create HTML container, and run dev/build.

// vite.config.js import { defineConfig } from 'vite'; import cesium from 'vite-plugin-cesium'; export default defineConfig({ plugins: [cesium()] }); // src/index.js import { Viewer } from 'cesium'; import './css/main.css'; const viewer = new Viewer('cesiumContainer'); // index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <script type="module" src="/src/index.js"></script> </head> <body> <div id="cesiumContainer"></div> </body> </html> // package.json scripts "scripts": { "dev": "vite", "build": "vite build" }
Debug
Known issues
breakingCesium 1.96.0 introduced changes that broke earlier versions of this plugin; fixed in v1.2.21.
fix
Upgrade to vite-plugin-cesium >=1.2.21 and ensure cesium >=1.96.0.
affects: <1.2.21
gotchaOn Windows, loading widgets.css may fail due to path resolution; fixed in v1.2.16.
fix
Update to >=1.2.16 or manually workaround path issues by using forward slashes.
affects: <1.2.16
gotchaThe plugin is ESM-only; using require() will throw an error.
fix
Use import syntax: import cesium from 'vite-plugin-cesium';
affects: >=1.0.0
deprecatedCesium is not a function error from v1.2.20 was a bug fixed in that same version.
fix
Upgrade to v1.2.21 or later.
affects: 1.2.20
gotchaIf using rebuildCesium: true, the build output may exceed default chunk size warnings; plugin sets chunkSizeWarningLimit to 5000.
fix
Expect larger bundle size when rebuilding from source; adjust Vite's build.chunkSizeWarningLimit if needed.
affects: >=1.2.13
Errors
Common errors & fixes
Error: [vite-plugin-cesium] cesium is not a function
Cesium version incompatibility with plugin versions <=1.2.20
fix
Upgrade vite-plugin-cesium to >=1.2.21 and cesium to ^1.96.0
Error: Cannot find module 'cesium' or its corresponding type declarations.
Missing cesium dependency or incorrect import path
fix
Run 'npm install cesium' and use import { Viewer } from 'cesium'
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html".
Missing or misconfigured base path for worker files (common when not using plugin)
fix
Use vite-plugin-cesium to automatically handle worker paths
TypeError: Cannot read properties of undefined (reading 'default')
Using require() with ESM-only Cesium
fix
Change to import * as Cesium from 'cesium' or import { Viewer } from 'cesium'
Upgrade
Version history
1.2.23latest on npm
Audit
Dependencies
cesiumrequiredPeer dependency: core Cesium library required for functionality
viterequiredPeer dependency: plugin for Vite build tool
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources