Compare commits
8 Commits
v1.x
...
e915298dfc
Author | SHA1 | Date | |
---|---|---|---|
e915298dfc | |||
a8d9479375 | |||
3c8bad430b | |||
564a6ece40 | |||
436466b519 | |||
352ba1eba5 | |||
08e0da60dd | |||
![]() |
50b3f7d545 |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Nshen
|
||||
Copyright (c) 2025 coder-xiaomo, 2021 Nshen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
40
README.md
40
README.md
@@ -1,3 +1,43 @@
|
||||
# ⚡ vite-plugin-cesium-next
|
||||
|
||||
> 本仓库 fork 自 [nshen/vite-plugin-cesium](https://github.com/nshen/vite-plugin-cesium)
|
||||
|
||||
本仓库在原仓库代码基础上,主要针对性修复/优化了以下问题
|
||||
- 相对路径问题:本仓库已支持在 vite.config.ts 中配置以下类型的 base: `'./'`, `'/'`, `'/foo/bar'`, `''`, `(不设置)` (新创建的项目 base 默认为 `'./'`,而原仓库针对 `'./'` 没有做很好的处理)
|
||||
- 资源请求路径:当 base 形如 `'/foo/bar'` 时,cesium 静态文件由 `/cesium...` 改为请求 `/foo/bar/cesium...`
|
||||
鉴于原仓库作者可能不再维护此项目(详见:[issue](https://github.com/nshen/vite-plugin-cesium/issues/62#issuecomment-2957419669)),故 fork 本仓库 ([coder-xiaomo/vite-plugin-cesium-next](https://github.com/coder-xiaomo/vite-plugin-cesium-next)) 继续维护,欢迎提交 Issue / Pr !
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i cesium vite-plugin-cesium-text vite -D
|
||||
# yarn add cesium vite-plugin-cesium-text vite -D
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
add this plugin to `vite.config.js`
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'vite';
|
||||
import cesium from 'vite-plugin-cesium-next'; // 👈 添加这一行
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
// ...
|
||||
cesium(), // 👈 添加这一行
|
||||
|
||||
// 或者如果你需要自定义配置,可以这样写 👇
|
||||
// cesium({ /* 这里可以添加配置 */ }),
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
以下是原仓库 README
|
||||
|
||||
# ⚡ vite-plugin-cesium
|
||||
|
||||
[](https://www.npmjs.com/package/vite-plugin-cesium)
|
||||
|
@@ -1,14 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>cesium-vite</title>
|
||||
<script type="module" src="/src/index.ts"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="cesiumContainer"></div>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>cesium-vite</title>
|
||||
<script type="module" src="/src/index.ts"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="cesiumContainer"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
499
demo/package-lock.json
generated
Normal file
499
demo/package-lock.json
generated
Normal file
@@ -0,0 +1,499 @@
|
||||
{
|
||||
"name": "cesium-demo",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cesium-demo",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"cesium": "1.129.0",
|
||||
"vite": "file:../node_modules/vite",
|
||||
"vite-plugin-cesium-next": "file:.."
|
||||
}
|
||||
},
|
||||
"..": {
|
||||
"version": "2.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fs-extra": "^11.3.0",
|
||||
"rollup-plugin-external-globals": "^0.6.1",
|
||||
"serve-static": "^1.16.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node22": "^22.0.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^22.15.31",
|
||||
"@types/serve-static": "^1.15.8",
|
||||
"prettier": "^3.5.3",
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^6.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"cesium": "^1.95.0",
|
||||
"vite": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"../node_modules/vite": {
|
||||
"version": "6.3.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup": "^4.34.9",
|
||||
"tinyglobby": "^0.2.13"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/vitejs/vite?sponsor=1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"less": "*",
|
||||
"lightningcss": "^1.21.0",
|
||||
"sass": "*",
|
||||
"sass-embedded": "*",
|
||||
"stylus": "*",
|
||||
"sugarss": "*",
|
||||
"terser": "^5.16.0",
|
||||
"tsx": "^4.8.1",
|
||||
"yaml": "^2.4.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"jiti": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"lightningcss": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"sass-embedded": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
},
|
||||
"tsx": {
|
||||
"optional": true
|
||||
},
|
||||
"yaml": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@cesium/engine": {
|
||||
"version": "17.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@cesium/engine/-/engine-17.0.0.tgz",
|
||||
"integrity": "sha512-bvLWmWVY4QX9rfcx/zfBzA8R1xR8KzmaCDOVL6pFkNZeYmRtt8JN//IICYR3P45lznlcb0Dklw1iCb37t4tvLA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tweenjs/tween.js": "^25.0.0",
|
||||
"@zip.js/zip.js": "^2.7.34",
|
||||
"autolinker": "^4.0.0",
|
||||
"bitmap-sdf": "^1.0.3",
|
||||
"dompurify": "^3.0.2",
|
||||
"draco3d": "^1.5.1",
|
||||
"earcut": "^3.0.0",
|
||||
"grapheme-splitter": "^1.0.4",
|
||||
"jsep": "^1.3.8",
|
||||
"kdbush": "^4.0.1",
|
||||
"ktx-parse": "^1.0.0",
|
||||
"lerc": "^2.0.0",
|
||||
"mersenne-twister": "^1.1.0",
|
||||
"meshoptimizer": "^0.23.0",
|
||||
"pako": "^2.0.4",
|
||||
"protobufjs": "^7.1.0",
|
||||
"rbush": "3.0.1",
|
||||
"topojson-client": "^3.1.0",
|
||||
"urijs": "^1.19.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cesium/widgets": {
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@cesium/widgets/-/widgets-12.0.0.tgz",
|
||||
"integrity": "sha512-5Re06LU8lRPEZInHrpOCGBiLoj9VNJ0JJtPrzdnw1qhIDpf3v1W75OJf59k8CCFvUYkZzuTTi8qTVbpzmcbOuw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@cesium/engine": "^17.0.0",
|
||||
"nosleep.js": "^0.12.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@protobufjs/aspromise": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
|
||||
"integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/base64": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/base64/-/base64-1.1.2.tgz",
|
||||
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/codegen": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/codegen/-/codegen-2.0.4.tgz",
|
||||
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/eventemitter": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
|
||||
"integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/fetch": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/fetch/-/fetch-1.1.0.tgz",
|
||||
"integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@protobufjs/aspromise": "^1.1.1",
|
||||
"@protobufjs/inquire": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@protobufjs/float": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/float/-/float-1.0.2.tgz",
|
||||
"integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/inquire": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/inquire/-/inquire-1.1.0.tgz",
|
||||
"integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/path": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/path/-/path-1.1.2.tgz",
|
||||
"integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/pool": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/pool/-/pool-1.1.0.tgz",
|
||||
"integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@protobufjs/utf8": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/@protobufjs/utf8/-/utf8-1.1.0.tgz",
|
||||
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@tweenjs/tween.js": {
|
||||
"version": "25.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@tweenjs/tween.js/-/tween.js-25.0.0.tgz",
|
||||
"integrity": "sha512-XKLA6syeBUaPzx4j3qwMqzzq+V4uo72BnlbOjmuljLrRqdsd3qnzvZZoxvMHZ23ndsRS4aufU6JOZYpCbU6T1A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-24.0.0.tgz",
|
||||
"integrity": "sha512-yZQa2zm87aRVcqDyH5+4Hv9KYgSdgwX1rFnGvpbzMaC7YAljmhBET93TPiTd3ObwTL+gSpIzPKg5BqVxdCvxKg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmmirror.com/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@zip.js/zip.js": {
|
||||
"version": "2.7.62",
|
||||
"resolved": "https://registry.npmmirror.com/@zip.js/zip.js/-/zip.js-2.7.62.tgz",
|
||||
"integrity": "sha512-OaLvZ8j4gCkLn048ypkZu29KX30r8/OfFF2w4Jo5WXFr+J04J+lzJ5TKZBVgFXhlvSkqNFQdfnY1Q8TMTCyBVA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"bun": ">=0.7.0",
|
||||
"deno": ">=1.0.0",
|
||||
"node": ">=16.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/autolinker": {
|
||||
"version": "4.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/autolinker/-/autolinker-4.1.5.tgz",
|
||||
"integrity": "sha512-vEfYZPmvVOIuE567XBVCsx8SBgOYtjB2+S1iAaJ+HgH+DNjAcrHem2hmAeC9yaNGWayicv4yR+9UaJlkF3pvtw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"pnpm": ">=10.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bitmap-sdf": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/bitmap-sdf/-/bitmap-sdf-1.0.4.tgz",
|
||||
"integrity": "sha512-1G3U4n5JE6RAiALMxu0p1XmeZkTeCwGKykzsLTCqVzfSDaN6S7fKnkIkfejogz+iwqBWc0UYAIKnKHNN7pSfDg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cesium": {
|
||||
"version": "1.129.0",
|
||||
"resolved": "https://registry.npmmirror.com/cesium/-/cesium-1.129.0.tgz",
|
||||
"integrity": "sha512-XDEJKLnr8s5/Q/1wcdZVEJCgx+xbgfDzkVKd9OxRZzYttazip6KffusMHexRdExVMPfDcTohuqcuHNxj9CUNFA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
"packages/engine",
|
||||
"packages/widgets"
|
||||
],
|
||||
"dependencies": {
|
||||
"@cesium/engine": "^17.0.0",
|
||||
"@cesium/widgets": "^12.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmmirror.com/dompurify/-/dompurify-3.2.6.tgz",
|
||||
"integrity": "sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==",
|
||||
"dev": true,
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/draco3d": {
|
||||
"version": "1.5.7",
|
||||
"resolved": "https://registry.npmmirror.com/draco3d/-/draco3d-1.5.7.tgz",
|
||||
"integrity": "sha512-m6WCKt/erDXcw+70IJXnG7M3awwQPAsZvJGX5zY7beBqpELw6RDGkYVU0W43AFxye4pDZ5i2Lbyc/NNGqwjUVQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/earcut": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/earcut/-/earcut-3.0.1.tgz",
|
||||
"integrity": "sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/grapheme-splitter": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
|
||||
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jsep": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/jsep/-/jsep-1.4.0.tgz",
|
||||
"integrity": "sha512-B7qPcEVE3NVkmSJbaYxvv4cHkVW7DQsZz13pUMrfS8z8Q/BuShN+gcTXrUlPiGqM2/t/EEaI030bpxMqY8gMlw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/kdbush": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/kdbush/-/kdbush-4.0.2.tgz",
|
||||
"integrity": "sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ktx-parse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/ktx-parse/-/ktx-parse-1.0.0.tgz",
|
||||
"integrity": "sha512-Z31kVizz4DF/6vo9YiSYVBhuXAfyQy9bGxlW3+mB5OELoZjfXVZQpRoctsx8IEDKxBd6SagXKo7qRvu38i8Jfg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lerc": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/lerc/-/lerc-2.0.0.tgz",
|
||||
"integrity": "sha512-7qo1Mq8ZNmaR4USHHm615nEW2lPeeWJ3bTyoqFbd35DLx0LUH7C6ptt5FDCTAlbIzs3+WKrk5SkJvw8AFDE2hg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/long": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmmirror.com/long/-/long-5.3.2.tgz",
|
||||
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/mersenne-twister": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz",
|
||||
"integrity": "sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/meshoptimizer": {
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmmirror.com/meshoptimizer/-/meshoptimizer-0.23.0.tgz",
|
||||
"integrity": "sha512-zAZcfhHE3wBbwEN8MfCMI9PKRyOpz8491wcR2dxkv3IlNwDZrq2hEs5JZVtzfBrmjWhBZZtZZUO0OBSNFq5iUQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nosleep.js": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmmirror.com/nosleep.js/-/nosleep.js-0.12.0.tgz",
|
||||
"integrity": "sha512-9d1HbpKLh3sdWlhXMhU6MMH+wQzKkrgfRkYV0EBdvt99YJfj0ilCJrWRDYG2130Tm4GXbEoTCx5b34JSaP+HhA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pako": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/pako/-/pako-2.1.0.tgz",
|
||||
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
|
||||
"dev": true,
|
||||
"license": "(MIT AND Zlib)"
|
||||
},
|
||||
"node_modules/protobufjs": {
|
||||
"version": "7.5.3",
|
||||
"resolved": "https://registry.npmmirror.com/protobufjs/-/protobufjs-7.5.3.tgz",
|
||||
"integrity": "sha512-sildjKwVqOI2kmFDiXQ6aEB0fjYTafpEvIBs8tOR8qI4spuL9OPROLVu2qZqi/xgCfsHIwVqlaF8JBjWFHnKbw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@protobufjs/aspromise": "^1.1.2",
|
||||
"@protobufjs/base64": "^1.1.2",
|
||||
"@protobufjs/codegen": "^2.0.4",
|
||||
"@protobufjs/eventemitter": "^1.1.0",
|
||||
"@protobufjs/fetch": "^1.1.0",
|
||||
"@protobufjs/float": "^1.0.2",
|
||||
"@protobufjs/inquire": "^1.1.0",
|
||||
"@protobufjs/path": "^1.1.2",
|
||||
"@protobufjs/pool": "^1.1.0",
|
||||
"@protobufjs/utf8": "^1.1.0",
|
||||
"@types/node": ">=13.7.0",
|
||||
"long": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/quickselect": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/quickselect/-/quickselect-2.0.0.tgz",
|
||||
"integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/rbush": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/rbush/-/rbush-3.0.1.tgz",
|
||||
"integrity": "sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"quickselect": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/topojson-client": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/topojson-client/-/topojson-client-3.1.0.tgz",
|
||||
"integrity": "sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"commander": "2"
|
||||
},
|
||||
"bin": {
|
||||
"topo2geo": "bin/topo2geo",
|
||||
"topomerge": "bin/topomerge",
|
||||
"topoquantize": "bin/topoquantize"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.8.0.tgz",
|
||||
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/urijs": {
|
||||
"version": "1.19.11",
|
||||
"resolved": "https://registry.npmmirror.com/urijs/-/urijs-1.19.11.tgz",
|
||||
"integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"resolved": "../node_modules/vite",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/vite-plugin-cesium-next": {
|
||||
"resolved": "..",
|
||||
"link": true
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,8 +9,8 @@
|
||||
"serve": "vite build && vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cesium": "1.96.0",
|
||||
"vite": "3.0.4",
|
||||
"vite-plugin-cesium": "link:.."
|
||||
"cesium": "1.129.0",
|
||||
"vite": "file:../node_modules/vite",
|
||||
"vite-plugin-cesium-next": "file:.."
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,12 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import cesium from 'vite-plugin-cesium';
|
||||
import cesium from 'vite-plugin-cesium-next';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [cesium()]
|
||||
// base: './',
|
||||
// base: '/',
|
||||
base: '/foo/bar',
|
||||
|
||||
plugins: [
|
||||
cesium(),
|
||||
],
|
||||
});
|
||||
|
3019
package-lock.json
generated
Normal file
3019
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vite-plugin-cesium",
|
||||
"version": "1.2.23",
|
||||
"name": "vite-plugin-cesium-next",
|
||||
"version": "2.0.0",
|
||||
"description": "Cesium library plugin for Vite",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
@@ -25,29 +25,32 @@
|
||||
"vite-plugin",
|
||||
"cesium"
|
||||
],
|
||||
"author": "nshen <nshen121@gmail.com>",
|
||||
"author": "coderxiaomo <codingzhang@126.com>",
|
||||
"contributors": [
|
||||
"nshen <nshen121@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nshen/vite-plugin-cesium"
|
||||
"url": "git+https://github.com/coder-xiaomo/vite-plugin-cesium-next"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nshen/vite-plugin-cesium/issues"
|
||||
"url": "https://github.com/coder-xiaomo/vite-plugin-cesium-next/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^9.1.0",
|
||||
"fs-extra": "^11.3.0",
|
||||
"rollup-plugin-external-globals": "^0.6.1",
|
||||
"serve-static": "^1.14.1"
|
||||
"serve-static": "^1.16.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@types/fs-extra": "^9.0.8",
|
||||
"@types/node": "^14.14.31",
|
||||
"@types/serve-static": "^1.13.9",
|
||||
"prettier": "^2.2.1",
|
||||
"tsup": "^6.2.1",
|
||||
"typescript": "^4.2.2",
|
||||
"vite": "^3.0.4"
|
||||
"@tsconfig/node22": "^22.0.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^22.15.31",
|
||||
"@types/serve-static": "^1.15.8",
|
||||
"prettier": "^3.5.3",
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^6.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"cesium": "^1.95.0",
|
||||
|
72
src/index.ts
72
src/index.ts
@@ -13,6 +13,7 @@ interface VitePluginCesiumOptions {
|
||||
cesiumBuildRootPath?: string;
|
||||
cesiumBuildPath?: string;
|
||||
cesiumBaseUrl?: string;
|
||||
viteBase?: string;
|
||||
}
|
||||
|
||||
export default function vitePluginCesium(options: VitePluginCesiumOptions = {}): Plugin {
|
||||
@@ -21,35 +22,52 @@ export default function vitePluginCesium(options: VitePluginCesiumOptions = {}):
|
||||
devMinifyCesium = false,
|
||||
cesiumBuildRootPath = 'node_modules/cesium/Build',
|
||||
cesiumBuildPath = 'node_modules/cesium/Build/Cesium/',
|
||||
cesiumBaseUrl = 'cesium/'
|
||||
cesiumBaseUrl = 'cesium/',
|
||||
viteBase = undefined,
|
||||
} = options;
|
||||
|
||||
let CESIUM_BASE_URL = cesiumBaseUrl;
|
||||
if (!CESIUM_BASE_URL.endsWith('/')) {
|
||||
CESIUM_BASE_URL += '/';
|
||||
const CESIUM_BASE_URL = cesiumBaseUrl.endsWith('/')
|
||||
? cesiumBaseUrl
|
||||
: (cesiumBaseUrl + '/');
|
||||
|
||||
const globalVars: {
|
||||
outDir: string,
|
||||
base: string,
|
||||
isBuild: boolean,
|
||||
cesiumRelativeUrl: string,
|
||||
} = {
|
||||
outDir: 'dist',
|
||||
base: '/',
|
||||
isBuild: false,
|
||||
cesiumRelativeUrl: '',
|
||||
}
|
||||
let outDir = 'dist';
|
||||
let base: string = '/';
|
||||
let isBuild: boolean = false;
|
||||
|
||||
return {
|
||||
name: 'vite-plugin-cesium',
|
||||
name: 'vite-plugin-cesium-next',
|
||||
|
||||
config(c, { command }) {
|
||||
isBuild = command === 'build';
|
||||
if (c.base !== undefined) {
|
||||
base = c.base;
|
||||
if (base === '') base = './';
|
||||
// 项目中 vite.config.ts 配置的 base 路径
|
||||
if (viteBase) {
|
||||
globalVars.base = viteBase;
|
||||
} else if (c.base) {
|
||||
globalVars.base = c.base;
|
||||
} else {
|
||||
globalVars.base = '/';
|
||||
}
|
||||
// 是否是打包命令
|
||||
globalVars.isBuild = command === 'build';
|
||||
// 输出路径
|
||||
if (c.build?.outDir) {
|
||||
outDir = c.build.outDir;
|
||||
globalVars.outDir = c.build.outDir;
|
||||
}
|
||||
CESIUM_BASE_URL = path.posix.join(base, CESIUM_BASE_URL);
|
||||
// 项目浏览器中运行时,Cesium 资源的相对路径
|
||||
globalVars.cesiumRelativeUrl = path.posix.join(globalVars.base, CESIUM_BASE_URL);
|
||||
|
||||
const userConfig: UserConfig = {};
|
||||
if (!isBuild) {
|
||||
if (!globalVars.isBuild) {
|
||||
// -----------dev-----------
|
||||
userConfig.define = {
|
||||
CESIUM_BASE_URL: JSON.stringify(CESIUM_BASE_URL)
|
||||
CESIUM_BASE_URL: JSON.stringify(globalVars.cesiumRelativeUrl)
|
||||
};
|
||||
} else {
|
||||
// -----------build------------
|
||||
@@ -60,7 +78,7 @@ export default function vitePluginCesium(options: VitePluginCesiumOptions = {}):
|
||||
chunkSizeWarningLimit: 5000,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
intro: `window.CESIUM_BASE_URL = ${JSON.stringify(CESIUM_BASE_URL)};`
|
||||
intro: `window.CESIUM_BASE_URL = ${JSON.stringify(globalVars.cesiumRelativeUrl)};`
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -79,7 +97,7 @@ export default function vitePluginCesium(options: VitePluginCesiumOptions = {}):
|
||||
|
||||
configureServer({ middlewares }) {
|
||||
const cesiumPath = path.join(cesiumBuildRootPath, devMinifyCesium ? 'Cesium' : 'CesiumUnminified');
|
||||
middlewares.use(path.posix.join('/', CESIUM_BASE_URL), serveStatic(cesiumPath, {
|
||||
middlewares.use(path.posix.join('/', globalVars.cesiumRelativeUrl), serveStatic(cesiumPath, {
|
||||
setHeaders: (res, path, stat) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*')
|
||||
}
|
||||
@@ -87,14 +105,14 @@ export default function vitePluginCesium(options: VitePluginCesiumOptions = {}):
|
||||
},
|
||||
|
||||
async closeBundle() {
|
||||
if (isBuild) {
|
||||
if (globalVars.isBuild) {
|
||||
try {
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Assets'), path.join(outDir, CESIUM_BASE_URL, 'Assets'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'ThirdParty'), path.join(outDir, CESIUM_BASE_URL, 'ThirdParty'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Workers'), path.join(outDir, CESIUM_BASE_URL, 'Workers'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Widgets'), path.join(outDir, CESIUM_BASE_URL, 'Widgets'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Assets'), path.join(globalVars.outDir, CESIUM_BASE_URL, 'Assets'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'ThirdParty'), path.join(globalVars.outDir, CESIUM_BASE_URL, 'ThirdParty'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Workers'), path.join(globalVars.outDir, CESIUM_BASE_URL, 'Workers'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Widgets'), path.join(globalVars.outDir, CESIUM_BASE_URL, 'Widgets'));
|
||||
if (!rebuildCesium) {
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Cesium.js'), path.join(outDir, CESIUM_BASE_URL, 'Cesium.js'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Cesium.js'), path.join(globalVars.outDir, CESIUM_BASE_URL, 'Cesium.js'));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('copy failed', err);
|
||||
@@ -108,15 +126,15 @@ export default function vitePluginCesium(options: VitePluginCesiumOptions = {}):
|
||||
tag: 'link',
|
||||
attrs: {
|
||||
rel: 'stylesheet',
|
||||
href: normalizePath(path.join(CESIUM_BASE_URL, 'Widgets/widgets.css')),
|
||||
href: normalizePath(path.join(globalVars.cesiumRelativeUrl, 'Widgets/widgets.css')),
|
||||
}
|
||||
}
|
||||
];
|
||||
if (isBuild && !rebuildCesium) {
|
||||
if (globalVars.isBuild && !rebuildCesium) {
|
||||
tags.push({
|
||||
tag: 'script',
|
||||
attrs: {
|
||||
src: normalizePath(path.join(CESIUM_BASE_URL, 'Cesium.js')),
|
||||
src: normalizePath(path.join(globalVars.cesiumRelativeUrl, 'Cesium.js')),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user