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.

31 lines
699 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. }
  10. }
  11. // FUNCTIONS
  12. //----------
  13. function buildVersion(): string {
  14. const version = pkg.version
  15. if (!isGitCommand()) {
  16. return version
  17. }
  18. const dirty = Number(execSync("git status -s | wc -l").toString())
  19. return dirty > 0 ? `${version}${dirty}` : version
  20. }
  21. function isGitCommand(): boolean {
  22. try {
  23. execSync("command -v git")
  24. return true
  25. } catch (e) {
  26. return false
  27. }
  28. }