Skip to content

Commit

Permalink
Merge pull request #24 from loosheng/tags-src-path
Browse files Browse the repository at this point in the history
fix: tags respect base path
  • Loading branch information
nshen authored Mar 28, 2022
2 parents 3e39226 + 557fb83 commit ad3c4e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
semi: true
tabWidth: 2
singleQuote: true
printWidth: 80
printWidth: 120
trailingComma: none
38 changes: 10 additions & 28 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit ad3c4e2

Please sign in to comment.