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
747 B
33 lines
747 B
import pkg from './package.json'
|
|
import { execSync } from 'child_process'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
export default {
|
|
plugins: [vue()],
|
|
define: {
|
|
APP_TITLE: JSON.stringify(pkg.name),
|
|
APP_VERSION: JSON.stringify(buildVersion()),
|
|
APP_ORIGIN: JSON.stringify(pkg.origin),
|
|
}
|
|
}
|
|
|
|
// FUNCTIONS
|
|
//----------
|
|
|
|
function buildVersion(): string {
|
|
const version = pkg.version
|
|
if (!isGitCommand()) {
|
|
return version
|
|
}
|
|
const dirty = Number(execSync("git status -s | wc -l").toString())
|
|
return dirty > 0 ? `${version}…${dirty}` : version
|
|
}
|
|
|
|
function isGitCommand(): boolean {
|
|
try {
|
|
execSync("command -v git")
|
|
return true
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
}
|