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.

37 lines
883 B

4 years ago
4 years ago
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. import WindiCSS from 'vite-plugin-windicss'
  5. export default {
  6. plugins: [
  7. vue(),
  8. WindiCSS()
  9. ],
  10. define: {
  11. APP_TITLE: JSON.stringify(pkg.name),
  12. APP_VERSION: JSON.stringify(buildVersion()),
  13. APP_REPOSITORY: JSON.stringify(pkg.repository),
  14. APP_LICENSE: JSON.stringify(pkg.license),
  15. }
  16. }
  17. // FUNCTIONS
  18. //----------
  19. function buildVersion(): string {
  20. const version = pkg.version
  21. if (!isGitCommand()) {
  22. return version
  23. }
  24. const dirty = Number(execSync("git status -s | wc -l").toString())
  25. return dirty > 0 ? `${version}${dirty}` : version
  26. }
  27. function isGitCommand(): boolean {
  28. try {
  29. execSync("command -v git")
  30. return true
  31. } catch (e) {
  32. return false
  33. }
  34. }