Merge pull request #24 from loosheng/tags-src-path
fix: tags respect base path
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
semi: true
|
||||
tabWidth: 2
|
||||
singleQuote: true
|
||||
printWidth: 80
|
||||
printWidth: 120
|
||||
trailingComma: none
|
38
src/index.ts
38
src/index.ts
@@ -77,37 +77,19 @@ function vitePluginCesium(
|
||||
},
|
||||
|
||||
configureServer({ middlewares }) {
|
||||
const cesiumPath = path.join(
|
||||
cesiumBuildRootPath,
|
||||
devMinifyCesium ? 'Cesium' : 'CesiumUnminified'
|
||||
);
|
||||
const cesiumPath = path.join(cesiumBuildRootPath, devMinifyCesium ? 'Cesium' : 'CesiumUnminified');
|
||||
middlewares.use(CESIUM_BASE_URL, serveStatic(cesiumPath));
|
||||
},
|
||||
|
||||
async closeBundle() {
|
||||
if (isBuild) {
|
||||
try {
|
||||
await fs.copy(
|
||||
path.join(cesiumBuildPath, 'Assets'),
|
||||
path.join(outDir, 'cesium/Assets')
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(cesiumBuildPath, 'ThirdParty'),
|
||||
path.join(outDir, 'cesium/ThirdParty')
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(cesiumBuildPath, 'Workers'),
|
||||
path.join(outDir, 'cesium/Workers')
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(cesiumBuildPath, 'Widgets'),
|
||||
path.join(outDir, 'cesium/Widgets')
|
||||
);
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Assets'), path.join(outDir, 'cesium/Assets'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'ThirdParty'), path.join(outDir, 'cesium/ThirdParty'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Workers'), path.join(outDir, 'cesium/Workers'));
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Widgets'), path.join(outDir, 'cesium/Widgets'));
|
||||
if (!rebuildCesium) {
|
||||
await fs.copy(
|
||||
path.join(cesiumBuildPath, 'Cesium.js'),
|
||||
path.join(outDir, 'cesium/Cesium.js')
|
||||
);
|
||||
await fs.copy(path.join(cesiumBuildPath, 'Cesium.js'), path.join(outDir, 'cesium/Cesium.js'));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('copy failed', err);
|
||||
@@ -121,16 +103,16 @@ function vitePluginCesium(
|
||||
tag: 'link',
|
||||
attrs: {
|
||||
rel: 'stylesheet',
|
||||
href: normalizePath(
|
||||
path.join(CESIUM_BASE_URL, 'Widgets/widgets.css')
|
||||
)
|
||||
href: base + normalizePath(path.join(CESIUM_BASE_URL, 'Widgets/widgets.css'))
|
||||
}
|
||||
}
|
||||
];
|
||||
if (isBuild && !rebuildCesium) {
|
||||
tags.push({
|
||||
tag: 'script',
|
||||
attrs: { src: normalizePath(path.join(base, 'cesium/Cesium.js')) }
|
||||
attrs: {
|
||||
src: base + normalizePath(path.join(CESIUM_BASE_URL, 'Cesium.js'))
|
||||
}
|
||||
});
|
||||
}
|
||||
return tags;
|
||||
|
Reference in New Issue
Block a user