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.

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