feat: copy to outDir
This commit is contained in:
32
src/index.ts
32
src/index.ts
@@ -65,47 +65,33 @@ function vitePluginCesium(
|
|||||||
middlewares.use(CESIUM_BASE_URL, serveStatic(cesiumPath));
|
middlewares.use(CESIUM_BASE_URL, serveStatic(cesiumPath));
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildStart() {
|
async closeBundle() {
|
||||||
if (isBuild) {
|
if (isBuild) {
|
||||||
const exists = await fs.pathExists(path.join(publicPath, 'cesium'));
|
|
||||||
|
|
||||||
if (!exists) {
|
|
||||||
try {
|
try {
|
||||||
await fs.copy(
|
await fs.copy(
|
||||||
path.join(cesiumBuildPath, 'Assets'),
|
path.join(cesiumBuildPath, 'Assets'),
|
||||||
path.join(publicPath, 'cesium/Assets')
|
path.join(outDir, 'cesium/Assets')
|
||||||
);
|
);
|
||||||
await fs.copy(
|
await fs.copy(
|
||||||
path.join(cesiumBuildPath, 'ThirdParty'),
|
path.join(cesiumBuildPath, 'ThirdParty'),
|
||||||
path.join(publicPath, 'cesium/ThirdParty')
|
path.join(outDir, 'cesium/ThirdParty')
|
||||||
);
|
);
|
||||||
await fs.copy(
|
await fs.copy(
|
||||||
path.join(cesiumBuildPath, 'Workers'),
|
path.join(cesiumBuildPath, 'Workers'),
|
||||||
path.join(publicPath, 'cesium/Workers')
|
path.join(outDir, 'cesium/Workers')
|
||||||
);
|
);
|
||||||
await fs.copy(
|
await fs.copy(
|
||||||
path.join(cesiumBuildPath, 'Widgets'),
|
path.join(cesiumBuildPath, 'Widgets'),
|
||||||
path.join(publicPath, 'cesium/Widgets')
|
path.join(outDir, 'cesium/Widgets')
|
||||||
|
);
|
||||||
|
await fs.copy(
|
||||||
|
path.join(cesiumBuildPath, 'Cesium.js'),
|
||||||
|
path.join(outDir, 'cesium/Cesium.js')
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('copy failed', err);
|
console.error('copy failed', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rebuildCesium) {
|
|
||||||
await fs.remove(path.join(publicPath, 'cesium/Cesium.js'));
|
|
||||||
} else {
|
|
||||||
await fs.copy(
|
|
||||||
path.join(cesiumBuildPath, 'Cesium.js'),
|
|
||||||
path.join(publicPath, 'cesium/Cesium.js')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async renderStart() {
|
|
||||||
const existOutDir = await fs.pathExists(path.join(outDir, 'cesium'));
|
|
||||||
if (existOutDir) {
|
|
||||||
await fs.remove(path.join(publicPath, 'cesium'));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
transformIndexHtml() {
|
transformIndexHtml() {
|
||||||
|
Reference in New Issue
Block a user