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.

43 lines
927 B

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