vite-plugin-mars3d

raw JSON →
4.2.2 verified Mon Apr 27 auth: no javascript

A Vite plugin for integrating Mars3D (a 3D GIS platform built on Cesium) into Vite projects. Current stable version 4.2.2, updated 2024-08-13. Provides seamless integration by handling Vite-specific configurations, copy assets, and optional CDN usage. Enables faster HMR and optimized builds for Mars3D applications. Key differentiators: easy setup, TypeScript support, and compatibility with latest Vite versions (v4+).

error Error: Cannot find module 'vite-plugin-mars3d'
cause Missing package installation.
fix
Run npm install vite-plugin-mars3d --save-dev
error TypeError: mars3dPlugin is not a function
cause Incorrect import: using CommonJS require instead of ESM import.
fix
Use import mars3dPlugin from 'vite-plugin-mars3d'
error [plugin:vite-plugin-mars3d] Failed to resolve import "mars3d" from "xxx"
cause Mars3D dependency not installed or incorrectly resolved.
fix
Ensure mars3d is installed: npm install mars3d
breaking v4.0+ drops support for Node.js 14 and Vite 3.x.
fix Upgrade to Node.js 16+ and Vite 4+.
deprecated Option 'useCDN' replaced by 'cdn' in v4.0.
fix Replace 'useCDN: true' with 'cdn: true'.
gotcha Plugin must be listed first in plugins array to work correctly.
fix Ensure mars3dPlugin() is the first element in plugins array.
gotcha When using TypeScript, ensure 'vite-plugin-mars3d' is included in tsconfig 'types' array for intellisense.
fix Add to tsconfig.json: "types": ["vite-plugin-mars3d"]
npm install vite-plugin-mars3d
yarn add vite-plugin-mars3d
pnpm add vite-plugin-mars3d

Basic setup of vite-plugin-mars3d in Vite config, enabling Mars3D integration.

// vite.config.ts
import { defineConfig } from 'vite';
import mars3dPlugin from 'vite-plugin-mars3d';

export default defineConfig({
  plugins: [mars3dPlugin()],
});