prebuild.js 628 B

12345678910111213141516171819202122232425
  1. console.log("> prebuild");
  2. console.log("> prebuild create .env.production.local");
  3. const buildDate = require("moment")().format("YYYY-MM-DD HH:mm:SS");
  4. console.log(" 构建日期为 " + buildDate);
  5. const revision = require("child_process")
  6. .execSync("git rev-parse HEAD")
  7. .toString()
  8. .trim()
  9. .slice(0, 7);
  10. const fs = require("fs");
  11. console.log(" 当前的git版本为 " + revision);
  12. fs.writeFileSync(
  13. ".env.production.local",
  14. "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
  15. );
  16. fs.writeFileSync(
  17. ".env.staging.local",
  18. "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
  19. );
  20. console.log();