ino-cesium 0.0.17-beta.2 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ino-cesium",
3
3
  "type": "module",
4
- "version": "0.0.17-beta.2",
4
+ "version": "0.0.17",
5
5
  "author": "koino",
6
6
  "keywords": [
7
7
  "cesium",
@@ -23,17 +23,18 @@
23
23
  },
24
24
  "files": [
25
25
  "dist/**",
26
+ "vite/**",
26
27
  "README.MD"
27
28
  ],
28
29
  "dependencies": {
29
- "@ino-cesium/analysis": "0.0.17-beta.2",
30
- "@ino-cesium/common": "0.0.17-beta.2",
31
- "@ino-cesium/draw": "0.0.17-beta.2",
32
- "@ino-cesium/effects": "0.0.17-beta.2",
33
- "@ino-cesium/layers": "0.0.17-beta.2",
34
- "@ino-cesium/material": "0.0.17-beta.2",
35
- "@ino-cesium/primitive": "0.0.17-beta.2",
36
- "vite-plugin-static-copy": "^3.1.0"
30
+ "vite-plugin-static-copy": "^3.1.0",
31
+ "@ino-cesium/analysis": "0.0.17",
32
+ "@ino-cesium/material": "0.0.17",
33
+ "@ino-cesium/draw": "0.0.17",
34
+ "@ino-cesium/effects": "0.0.17",
35
+ "@ino-cesium/layers": "0.0.17",
36
+ "@ino-cesium/common": "0.0.17",
37
+ "@ino-cesium/primitive": "0.0.17"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "cesium": "1.131.0"
@@ -0,0 +1,12 @@
1
+ import type * as vite from 'vite'
2
+
3
+ declare function inoCesiumVitePlugin(options?: {
4
+ /**
5
+ * 打包时是否复制js和dts等, 默认值只复制assets静态资源
6
+ */
7
+ copyJs?: boolean
8
+ }): (vite.Plugin<any> | vite.Plugin<any>[])[]
9
+
10
+ export {
11
+ inoCesiumVitePlugin,
12
+ }
package/vite/index.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * 主要做根目录配置和静态资源处理,
3
+ * 类似vite-plugin-cesiumjs.
4
+ */
5
+ import { viteStaticCopy } from 'vite-plugin-static-copy'
6
+
7
+ const inoCesiumBaseUrl = () => {
8
+ return {
9
+ name: 'ino-cesium-base-url',
10
+ enforce: 'post',
11
+ transformIndexHtml: {
12
+ order: 'post',
13
+ handler(_html, { server }) {
14
+ let scriptList = []
15
+ if (server) {
16
+ const { base, command } = server.config
17
+ if (command === 'serve') {
18
+ scriptList = [
19
+ {
20
+ tag: 'script',
21
+ children: ` window.INO_CESIUM_BASE_URL = '${base}node_modules/ino-cesium/src'; `,
22
+ injectTo: 'head-prepend',
23
+ },
24
+ ]
25
+ }
26
+ }
27
+ else {
28
+ scriptList = [{
29
+ tag: 'script',
30
+ children: ` window.INO_CESIUM_BASE_URL = '/ino-cesium'; `,
31
+ injectTo: 'head-prepend',
32
+ }]
33
+ }
34
+ return scriptList
35
+ },
36
+ },
37
+ }
38
+ }
39
+
40
+ const inoCesiumStatic = (options) => {
41
+ let targets = []
42
+ if (options.copyJs) {
43
+ targets = [
44
+ {
45
+ src: `node_modules/ino-cesium/dist/*`,
46
+ dest: `ino-cesium/`,
47
+ },
48
+ ]
49
+ }
50
+ else {
51
+ targets = [
52
+ {
53
+ src: `node_modules/ino-cesium/dist/assets/*`,
54
+ dest: `ino-cesium/assets/`,
55
+ },
56
+ ]
57
+ }
58
+
59
+ const plugins = viteStaticCopy({
60
+ silent: true,
61
+ targets,
62
+ })
63
+ return plugins
64
+ }
65
+
66
+ export const inoCesiumVitePlugin = (options = {}) => {
67
+ const plugins = [inoCesiumBaseUrl(), inoCesiumStatic(options)]
68
+ return plugins
69
+ }