fix: mars3d-cesium must start with either "/",
This commit is contained in:
parent
024cf96cc7
commit
0cb418be2a
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vite-plugin-earth",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"description": "Cesium & Mars3D library plugin for Vite",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
@ -37,7 +37,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^9.1.0",
|
||||
"rollup-plugin-external-globals": "^0.6.1",
|
||||
"rollup-plugin-external-globals": "^0.8.0",
|
||||
"serve-static": "^1.14.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -48,7 +48,7 @@
|
|||
"prettier": "^2.2.1",
|
||||
"tsup": "^6.2.1",
|
||||
"typescript": "^4.2.2",
|
||||
"vite": "^4.3.4"
|
||||
"vite": "^4.3.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": ">=2.7.1"
|
||||
|
|
21
src/index.ts
21
src/index.ts
|
@ -90,16 +90,16 @@ export function mars3dPlugin(options: VitePluginMars3dOptions = {}): Plugin {
|
|||
};
|
||||
} else {
|
||||
// build 2) copy Cesium.js later
|
||||
let external = [CESIUM_NAME];
|
||||
let plugins = [externalGlobals({ cesium: 'Cesium' })];
|
||||
|
||||
external.push('mars3d');
|
||||
plugins.push(externalGlobals({ mars3d: 'mars3d' }));
|
||||
const external = [CESIUM_NAME, 'mars3d'];
|
||||
const globalsLibs = {
|
||||
mars3d: 'mars3d',
|
||||
'mars3d-cesium': 'Cesium'
|
||||
};
|
||||
|
||||
userConfig.build = {
|
||||
rollupOptions: {
|
||||
external: external,
|
||||
plugins: plugins
|
||||
plugins: [externalGlobals(globalsLibs)]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -187,10 +187,15 @@ export function mars3dPlugin(options: VitePluginMars3dOptions = {}): Plugin {
|
|||
}
|
||||
});
|
||||
if (isBuild && !rebuildCesium) {
|
||||
tags.push({
|
||||
tag: 'script',
|
||||
children: `window['CESIUM_BASE_URL'] = '${CESIUM_BASE_URL}'`
|
||||
});
|
||||
|
||||
tags.push({
|
||||
tag: 'script',
|
||||
attrs: {
|
||||
src: normalizePath(path.join(base, `${CESIUM_NAME}/Cesium.js`))
|
||||
src: normalizePath(path.join(CESIUM_BASE_URL, `Cesium.js`))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -203,7 +208,7 @@ export function mars3dPlugin(options: VitePluginMars3dOptions = {}): Plugin {
|
|||
}
|
||||
});
|
||||
|
||||
if (isBuild && !rebuildCesium) {
|
||||
if (isBuild) {
|
||||
tags.push({
|
||||
tag: 'script',
|
||||
attrs: {
|
||||
|
|
Loading…
Reference in New Issue