Files
Gacy-Srtool/scripts/build-vercel.cjs
T

29 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-10-29 00:13:34 +07:00
// Only the static web application is published; repository tools and local
// configuration are not copied to the public deployment.
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const output = path.join(root, 'dist');
fs.mkdirSync(output, { recursive: true });
// If building on Vercel, update version.json with the deployed branch
const vercelBranch = process.env.VERCEL_GIT_COMMIT_REF;
const versionFile = path.join(root, 'version.json');
if (vercelBranch && fs.existsSync(versionFile)) {
try {
const data = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
data.branch = vercelBranch;
data.updatedAt = new Date().toISOString();
fs.writeFileSync(versionFile, JSON.stringify(data, null, 2) + '\n');
console.log(`[build-vercel] Synced branch to: ${vercelBranch}`);
} catch (err) {
console.warn('[build-vercel] Could not update branch:', err.message);
}
}
2026-10-29 00:13:34 +07:00
for (const name of ['index.html', 'version.json', 'assets', 'css', 'js']) {
const source = path.join(root, name);
if (!fs.existsSync(source)) throw new Error(`Missing static application input: ${name}`);
fs.cpSync(source, path.join(output, name), { recursive: true, force: true });
}
console.log('Static application prepared for Vercel.');