2022-02-11 15:44:52 +08:00
|
|
|
# ⚡ vite-plugin-earth
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
Easily set up a [`cesium`] & [`mars3d-cesium`] project in [`Vite`].
|
2022-02-10 13:08:07 +08:00
|
|
|
|
|
|
|
[`cesium`]: https://github.com/CesiumGS/cesium
|
|
|
|
[`mars3d`]: https://mars3d.cn/
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
2022-07-14 14:51:49 +08:00
|
|
|
npm i vite-plugin-earth -D
|
2022-02-10 13:08:07 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
add this plugin to `vite.config.js`
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
2022-07-14 14:51:49 +08:00
|
|
|
import earth from 'vite-plugin-earth';
|
2022-02-10 13:08:07 +08:00
|
|
|
export default defineConfig({
|
2022-07-14 14:51:49 +08:00
|
|
|
plugins: [earth()]
|
2022-02-10 13:08:07 +08:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
## Options
|
|
|
|
|
|
|
|
### **pkgName**
|
|
|
|
|
|
|
|
- **Type :** `string`
|
|
|
|
- **Default :** `cesium`
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
`mars3d-cesium` 为`mars3d`对应的依赖库
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import earth from 'vite-plugin-earth';
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
|
|
|
earth({
|
|
|
|
pkgName: 'mars3d-cesium'
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
2022-02-10 13:08:07 +08:00
|
|
|
```
|
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
### **libPath**
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
- **Type :** `string`
|
|
|
|
- **Default :** `lib`
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
将类库复制到指定的`lib/`目录下面
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import earth from 'vite-plugin-earth';
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
|
|
|
earth({
|
|
|
|
libPath: 'lib'
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
```
|
2022-02-10 13:08:07 +08:00
|
|
|
|
2022-07-14 14:51:49 +08:00
|
|
|
### **rebuildCesium**
|
2022-02-10 13:08:07 +08:00
|
|
|
|
|
|
|
- **Type :** `boolean`
|
|
|
|
- **Default :** `false`
|
|
|
|
|
|
|
|
Default copy min cesium file to dist. if `true` will rebuild cesium from source.
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from 'vite';
|
2022-07-14 14:51:49 +08:00
|
|
|
import earth from 'vite-plugin-earth';
|
2022-02-10 13:08:07 +08:00
|
|
|
export default defineConfig({
|
|
|
|
plugins: [
|
2022-07-14 14:51:49 +08:00
|
|
|
earth({
|
2022-02-10 13:08:07 +08:00
|
|
|
rebuildCesium: true
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
```
|