2022-02-11 15:44:52 +08:00
|
|
|
# ⚡ vite-plugin-earth
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-02-11 15:44:52 +08:00
|
|
|
Easily set up a [`Cesium`] & [`mars3d`] project in [`Vite`].
|
2022-02-10 13:08:07 +08:00
|
|
|
|
|
|
|
[`cesium`]: https://github.com/CesiumGS/cesium
|
|
|
|
[`mars3d`]: https://mars3d.cn/
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
2022-02-11 15:44:52 +08:00
|
|
|
npm i cesium vite-plugin-earth vite -D
|
|
|
|
# yarn add cesium vite-plugin-earth vite -D
|
2022-02-10 13:08:07 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
add this plugin to `vite.config.js`
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
2022-02-11 15:44:52 +08:00
|
|
|
import earthPlugin from 'vite-plugin-earth';
|
2022-02-10 13:08:07 +08:00
|
|
|
export default defineConfig({
|
2022-02-11 15:44:52 +08:00
|
|
|
plugins: [earthPlugin()]
|
2022-02-10 13:08:07 +08:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
add dev command to `package.json`
|
|
|
|
|
|
|
|
```json
|
|
|
|
"scripts": {
|
|
|
|
"dev": "vite",
|
|
|
|
"build": "vite build"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
run:
|
|
|
|
|
|
|
|
`yarn dev`
|
|
|
|
|
|
|
|
## Options
|
|
|
|
|
|
|
|
**rebuildCesium**
|
|
|
|
|
|
|
|
- **Type :** `boolean`
|
|
|
|
- **Default :** `false`
|
|
|
|
|
|
|
|
Default copy min cesium file to dist. if `true` will rebuild cesium from source.
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
2022-02-11 15:44:52 +08:00
|
|
|
import earthPlugin from 'vite-plugin-earth';
|
2022-02-10 13:08:07 +08:00
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
2022-02-11 15:44:52 +08:00
|
|
|
earthPlugin({
|
2022-02-10 13:08:07 +08:00
|
|
|
rebuildCesium: true
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
```
|