chore(dx/server): trigger build of client & copy artifacts

This commit is contained in:
Elian Doran
2025-08-31 23:03:21 +03:00
parent f4a56d4e19
commit a06f2aeb8b

View File

@@ -1,6 +1,7 @@
import * as esbuild from "esbuild";
import { join } from "path";
import * as fs from "fs-extra";
import * as child_process from "child_process";
const projectDir = __dirname + "/..";
const outDir = join(projectDir, "dist");
@@ -51,6 +52,17 @@ function copyAssets() {
copy("../../packages/share-theme/src/templates", "share-theme/templates/");
}
function buildAndCopyClient() {
// Trigger the build.
child_process.execSync("pnpm build", { cwd: clientDir, stdio: "inherit" });
// Copy the artifacts.
copy("../client/dist", "public/");
// Remove unnecessary files.
deleteFromOutput("public/webpack-stats.json");
}
function copy(projectDirPath: string, outDirPath: string) {
if (outDirPath.endsWith("/")) {
fs.mkdirpSync(join(outDirPath));
@@ -58,10 +70,15 @@ function copy(projectDirPath: string, outDirPath: string) {
fs.copySync(join(projectDir, projectDirPath), join(outDir, outDirPath), { dereference: true });
}
function deleteFromOutput(path: string) {
fs.rmSync(join(outDir, path), { recursive: true });
}
async function main() {
fs.emptyDirSync(outDir);
await build();
copyAssets();
buildAndCopyClient();
}
main();