Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tags respect base path #24

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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