not exactly global -
you have to make it available in every component you want to use it.
define some env options in your quasar.config.js
file:
const packageInfo = require('./package.json')
const { configure } = require('quasar/wrappers');
module.exports = configure(function (ctx) {
return {
// ....
build: {
// ....
env: {
// https://forum.quasar-framework.org/topic/6853/auto-generate-a-build-number-in-spa/15?_=1653270667151
// https://quasar.dev/quasar-cli-webpack/handling-process-env#caveats
// TEST: "42",
appinfo: {
name: packageInfo.name,
version: packageInfo.version,
productName: packageInfo.productName,
description: packageInfo.description,
projectUrl: packageInfo.projectUrl,
previewUrl: packageInfo.previewUrl,
},
},
},
// ....
}
});
than you need to include something like this in 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>
// https://quasar.dev/quasar-cli-webpack/handling-process-env#caveats
// console.log(process.env.TEST)
const appinfo = process.env.appinfo
</script>
or for the script part the older way:
<script>
export default {
name: 'AboutPage',
data () {
// https://quasar.dev/quasar-cli-webpack/handling-process-env#caveats
// console.log(process.env.TEST)
return {
appinfo: process.env.appinfo,
}
}
}
</script>