Browse Source

configuration constants

master
pvincent 4 years ago
parent
commit
80d0ebdc97
  1. 2
      TODO.md
  2. 14
      src/App.vue
  3. 8
      src/main.ts
  4. 2
      src/shims-vue.d.ts
  5. 30
      vite.config.ts

2
TODO.md

@ -1,12 +1,14 @@
TODO
====
## ARCHI
* [ ] composition API
* [ ] eslint
* [ ] WindyCss
## FEATURE
* [ ] login/logout
* [ ] fake rest api
* [ ] i18n

14
src/App.vue

@ -1,15 +1,27 @@
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="vapara-vue3" />
<br />
{{ title }}
<br />
{{ version }}
<br />
</template>
<script lang="ts">
import HelloWorld from "./components/HelloWorld.vue";
console.log(APP_TITLE);
console.log(APP_VERSION);
export default {
name: "App",
components: {
HelloWorld,
},
data() {
return {
title: APP_TITLE,
version: APP_VERSION,
};
},
};
</script>

8
src/main.ts

@ -2,9 +2,5 @@ import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
console.log("Starting vite ...")
document.title = "YOUPI"
createApp(App).mount('#app')
console.log(`main.ts loaded`)
document.title = APP_TITLE
createApp(App).mount('#app')

2
src/shims-vue.d.ts

@ -2,4 +2,4 @@ declare module "*.vue" {
import { defineComponent } from "vue"
const Component: ReturnType<typeof defineComponent>
export default Component
}
}

30
vite.config.ts

@ -1,6 +1,30 @@
import pkg from './package.json'
import { execSync } from 'child_process'
const gitVersion = execSync("git describe --tags `git rev-list --tags --max-count=1`").toString()
console.log(gitVersion)
console.log(`vite.config.js loaded ${JSON.stringify(pkg.version)}`)
export default {
define: {
APP_TITLE: pkg.name,
APP_VERSION: buildVersion(),
}
}
// FUNCTIONS
//----------
function buildVersion(): string {
const version = pkg.version
if (!isGitCommand()) {
return version
}
const dirty = execSync("git status -s | wc -l").toString()
return `${version}${dirty}`
}
function isGitCommand() {
try {
execSync("command -v git")
return true
} catch (e) {
return false
}
}
Loading…
Cancel
Save