perf(web): skip unchanged incremental web builds
This commit is contained in:
23
tools/web/incremental-web-build.mjs
Normal file
23
tools/web/incremental-web-build.mjs
Normal file
@@ -0,0 +1,23 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import { fingerprint, readState, root, writeState } from "./web-build-fingerprint.mjs";
|
||||
|
||||
const currentFingerprint = fingerprint();
|
||||
const state = readState("web-build-success.json");
|
||||
const index = `${root}/web/dist/index.html`;
|
||||
if (state?.fingerprint === currentFingerprint && fs.existsSync(index)) {
|
||||
process.stdout.write(`web-build-reused fingerprint=${currentFingerprint}\n`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const typecheck = spawnSync(process.execPath, ["tools/web/run-incremental-typecheck.mjs"], {
|
||||
cwd: root,
|
||||
stdio: "inherit",
|
||||
});
|
||||
if (typecheck.status !== 0) process.exit(typecheck.status ?? 1);
|
||||
const vite = spawnSync(process.execPath, ["./node_modules/vite/bin/vite.js", "build", "--config", "app/vite.config.ts"], {
|
||||
cwd: `${root}/web`,
|
||||
stdio: "inherit",
|
||||
});
|
||||
if (vite.status !== 0) process.exit(vite.status ?? 1);
|
||||
writeState("web-build-success.json", { schemaVersion: 1, fingerprint: currentFingerprint });
|
||||
Reference in New Issue
Block a user