You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
747 B

4 years ago
4 years ago
4 years ago
4 years ago
  1. import pkg from './package.json'
  2. import { execSync } from 'child_process'
  3. import vue from '@vitejs/plugin-vue'
  4. export default {
  5. plugins: [vue()],
  6. define: {
  7. APP_TITLE: JSON.stringify(pkg.name),
  8. APP_VERSION: JSON.stringify(buildVersion()),
  9. APP_ORIGIN: JSON.stringify(pkg.origin),
  10. }
  11. }
  12. // FUNCTIONS
  13. //----------
  14. function buildVersion(): string {
  15. const version = pkg.version
  16. if (!isGitCommand()) {
  17. return version
  18. }
  19. const dirty = Number(execSync("git status -s | wc -l").toString())
  20. return dirty > 0 ? `${version}${dirty}` : version
  21. }
  22. function isGitCommand(): boolean {
  23. try {
  24. execSync("command -v git")
  25. return true
  26. } catch (e) {
  27. return false
  28. }
  29. }