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