It's not a completely global solution - you have to make it accessible in each component where you want to use it.
To define some environment options, add the following code to your quasar.config.js
file:
const packageInfo = require('./package.json')
const { configure } = require('quasar/wrappers');
module.exports = configure(function (ctx) {
return {
// ...
build: {
// ...
env: {
appinfo: {
name: packageInfo.name,
version: packageInfo.version,
productName: packageInfo.productName,
description: packageInfo.description,
projectUrl: packageInfo.projectUrl,
previewUrl: packageInfo.previewUrl,
},
},
},
// ...
}
});
Next, include something similar to this in your YourComponent.vue
file:
<template>
<q-page
class="flex column"
style="align-items: center;"
>
<section>
<h4>{{ appinfo.productName }}</h4>
<p>
version: v{{ appinfo.version }}
</p>
<p>
{{ appinfo.description }}<br>
find the project repository at <br>
<a
target="_blank"
:href="appinfo.projectUrl"
>
{{ appinfo.projectUrl }}
</a>
</p>
<p>
a live preview version is hosted at<br>
<a
target="_blank"
:href="appinfo.previewUrl"
>
{{ appinfo.previewUrl }}
</a>
</p>
</section>
</q-page>
</template>
<script setup>
const appinfo = process.env.appinfo
</script>
Alternatively, for the script section using a more traditional approach:
<script>
export default {
name: 'AboutPage',
data () {
return {
appinfo: process.env.appinfo,
}
}
}
</script>